Get querystring from Url in template

Hello-

I am relatively new to Grav and I have built my first site with it, but I am trying some new ideas and I immediately ran into a problem: I didn’t know how to fetch the query string from the URL when processing my twig templates.

I began combing the documentation, dumping out stuff with page|print_r and header|print_r and making wild guesses at other globals, google “grav query string” etc, but I couldn’t find anything.

What is, if it is anything, the way to get at the query string when rendering a page?

And while we’re here, what other global collections like “page” and “header” are available? (I couldn’t find an explicit discussion of this in the docs).

Thank you very much.

@claycle, Read some more docs… :wink:

On doc page Theme Variables:

  • See Quick Menu for other theme variables

  • From the Quick Menu, try URI:

    The whole list of the Uri object methods is available on the API site. Here’s a list of the methods you’ll find most useful.

    The Uri object has several methods to access parts of the current URI. For the full URL http://mysite.com/grav/section/category/page.json/param1:foo/param2:bar/?query1=baz&query2=qux

You’ll find more details on classes on doc page Grav API:

AHA. Thank you. I never would have thought to look at “theme” variables as this seems more like “page” variables coming at it new.

Mindset altered.

Thank you.

@claycle, Well… it’s mostly themes in which you create templates and use objects and variables… Maybe it should have been called “Template Variables”.

Page variables? Nah, the variables are of all sorts: config (System, Site, Theme, Plugin, …), Media, Taxonomy, User, …