Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

First level active Item

Started by Jan 8 years ago · 0 replies · 671 views
8 years ago

I am a 3 level menu structure and I need the active parent on the first level. Is there any better way to do a loop searching for the page that is "activeChild" = true or doing this:

{% if page.parent.root %}
{% set bodyClass = page.slug() %}
{# {% set bodyClass = root.children.activeChild().first().slug() %} #}
{% elseif page.parent.parent.root %}
{% set bodyClass = page.parent.slug() %}
{% else %}
{% set bodyClass = page.parent.parent.slug() %}
{% endif %}

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 1 day ago
2 42 20 hours ago
General · by Hanns Mattes, 1 week ago
0 123 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago