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:
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:... 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.You can use it in a template. For instance, you can grab a variable...
And then use that variable in a PageList lookup, similar to:
Then you can iterate over that array to print stuff out...eg
Props to the C5 Cheatsheet for the PageList code.