具体5:我可以在常规页面上使用$ _GET变量作为查询字符串吗? [英] Concrete5: Can I use $_GET variable for query string on Regular Page?

查看:143
本文介绍了具体5:我可以在常规页面上使用$ _GET变量作为查询字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<_> $ _GET变量如何与Concrete5一起使用?我可以在常规页面上使用它吗?



我知道我可以通过网址做到这一点,我只是想知道是否可以使用常规页面。 / p>

例如: http:/ /www.domain_name.com/about-us/?name=test ...

解决方案

获取参数通过控制器可用。在页面或块的使用视图中:

  $ this-> controller-> get(parameterName); 

定制参数的一个更简洁的方法是在函数视图中定义它们()的页面控制器。如果在 http://www.domain_name.com/about-us 是您的页面并且您定义了它的pagetype控制器的视图函数是这样的:

pre $ 函数视图($ name){
$ this-> set(name,$ name);
}

...并呼叫网址 http://www.domain_name.com/about-us/test - 那么test会在<$ c $下传递c> $ name 到您的页面视图。



请注意,页面类型的控制器必须位于 controllers / page_types / ,名为 BlablaPageTypeController ...与PageType直接在那里。


How does $_GET Variable works with Concrete5? Can I use that on regular page?

I know I can do this with single page via url segment, I'm just wondering if it is possible with regular page.

Example is :http://www.domain_name.com/about-us/?name=test...

解决方案

Get-parameters are available via the controllers. In the view of a page or block use:

$this->controller->get("parameterName");

A cleaner way for custom parameters would be to define them in the function view() of the page controller. If at http://www.domain_name.com/about-us is your page and you define the view function of it's pagetype controller like this:

function view($name) {
    $this->set("name", $name);
}

... and call the URL http://www.domain_name.com/about-us/test – then "test" will be passed under $name to your page view.

Note that controllers for page types must be in controllers/page_types/ and called BlablaPageTypeController ... with "PageType" literally being in there.

这篇关于具体5:我可以在常规页面上使用$ _GET变量作为查询字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆