Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

First level active Item

Started by Jan 8 years ago · 0 replies · 540 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 jeremycherfas, 1 week ago
4 181 2 days ago
General · by lynbor, 6 days ago
2 122 3 days ago
General · by Old Man Umby, 1 week ago
1 100 1 week ago
General · by Sebastian, 1 week ago
1 124 1 week ago
General · by Andy Miller, 3 weeks ago
0 248 3 weeks ago