Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Access the Taxonomy Filter in Twig

Started by Clemens HOLLEIS 7 years ago · 1 replies · 693 views
7 years ago

Hi,
I'm wondering how can i access the taxonomy filter passed via the url in my TWIG-Template.

Simple example
i filter a events for the tag concert and want to print the used filter word on my page...
url: www.mydomain.com/eventslist/tag:concert

how can i print the "concert" tag filter in my twig template?
{{ page.url }} returns only the url without the tag section

br Clemens

7 years ago

@clemens, Try uri instead of url

{{ var_dump(uri.params) }} returns: '/tag:concert'

{{ var_dump(uri.extractParams(uri, ':')) }} returns:

JS
array (size=2)
  0 => string 'http://localhost' (length=16)
  1 => 
    array (size=1)
      'tag' => string 'concert' (length=7)

{{ var_dump(uri.extractParams(uri, ':')[1]['tag']) }} returns: 'concert'

For more functions available for Uri, see Class: \Grav\Common\Uri

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Hanns Mattes, 1 day ago
1 36 21 hours ago
General · by Andy Miller, 21 hours ago
0 31 21 hours ago
General · by Jerry Hunt, 5 days ago
2 154 2 days ago
General · by pamtbaau, 2 days ago
1 102 2 days ago
General · by Andy Miller, 3 days ago
0 86 3 days ago