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

First level active Item

Started by Jan 8 years ago · 0 replies · 514 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 jean-louis67, 3 weeks ago
2 308 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 310 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 264 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago