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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

First level active Item

Started by Jan 8 years ago · 0 replies · 402 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 Jerry Hunt, 4 days ago
2 95 14 hours ago
General · by pamtbaau, 20 hours ago
1 61 19 hours ago
General · by Andy Miller, 1 day ago
0 47 1 day ago
General · by Marcel, 12 months ago
6 356 5 days ago
General · by Duc , 6 days ago
3 44 6 days ago