<p>I have a section (structure) called "blog" but "blog" is not in the URL.</p>

<p>I have entries like:</p>

<p>Entry 1a<br>
--Entry 1b<br>
----Entry 1c<br>
Entry 2a<br>
---Entry 2b</p>

<p>A navigation like:</p>

<p>Overview &lt;- a template in the root directory<br>
Entry 1a<br>
Entry 2a</p>

<p>I need to set "Overview" to active on all entries.
Entry 1a should be active if itself or child's are shown.
Entry 2a should be active if itself or child's are shown.</p>

<p>Doing this by hand for all entries would be a pain:</p>

<pre><code>{% if craft.request.firstSegment == 'Entry 1a or Entry 1b' %}active{% endif %}
</code></pre>

CC BY-SA 4.0
2019-08-07T12:34:18.233Z
Have you tries using levels? something like `{% if entry.level == 1 %}active{% endif %}`
KSPR
CC BY-SA 4.0
2019-08-07T15:43:24.480Z
@KSPR 1a and 2a or 1b and 2b are on the same level. So it wont work.
MrGlasspoole
<craft3><navigation>
Set active class on parrents in a structure?
# Set active class on parrents in a structure?

(Asked by: username_0 on 2019-08-07)

I have a section (structure) called "blog" but "blog" is not in the URL.
I have entries like:
Entry 1a
--Entry 1b
----Entry 1c
Entry 2a
---Entry 2b
A navigation like:
Overview <- a template in the root directory
Entry 1a
Entry 2a
I need to set "Overview" to active on all entries.
Entry 1a should be active if itself or child's are shown.
Entry 2a should be active if itself or child's are shown.
Doing this by hand for all entries would be a pain:
{% if craft.request.firstSegment == 'Entry 1a or Entry 1b' %}active{% endif %}

**Tags:** craft3, navigation

> **Comments:**
> **username_1**: Have you tries using levels? something like `{% if entry.level == 1 %}active{% endif %}`  
> **username_0**: @username_1 1a and 2a or 1b and 2b are on the same level. So it wont work.  

---

## 0 answers

