How would I go about parsing URL parameters in a Twig template? Say I had a page that was access with like the following /grav/page/?red=255&green=255&blue=255
, how could I access the values of these parameters by keys? I’m assuming, of course, that Twig extends PHP far enough to allow for maps, ie. indexed or associative arrays.
you can pass query parameters this way:
{{ uri.query('red') }}
or you can use the cleaner looking grav specific params.
http://yourgravsite.com/red:255/green:150/blue:102
Then to access them you use the URI object which is available in Twig:
{{ uri.param('red') }}}
Ah, I was unaware that the query
function took parameters of its own, thanks!