<p>The lastSegment will always have length whether it's 2, 3, 4 etc. I am unclear about your Structure setup, but if there is nothing after "modules", "modules" is the last segment and therefore exists.</p>

<p>So maybe something like:</p>

<pre><code>{% if craft.request.getSegment(2) == 'modules' and not craft.request.getSegment(3)|length %}
</code></pre>

CC BY-SA 3.0
2016-06-15T13:12:20.900Z
Thank you for setting me on the right track. I was able to accomplish what I wanted with the following.
`{% if craft.request.getSegment(2) == 'modules' and not craft.request.getSegment(3)|length %}`
julzmon
CC BY-SA 3.0
2016-06-16T07:23:46.650Z
I added "not" to the answer above that I had originally left out.
AbbeyDesign
CC BY-SA 3.0
2016-06-15T09:14:24.377Z
2016-06-16T07:20:39.633Z
2016-06-16T07:20:39.633Z
AbbeyDesign
<p>How do I display something only for one of the parent Structure sections and not others or this sections children?
I was thinking of using</p>

<pre><code>{% if craft.request.segment(2) == 'modules' and craft.request.lastSegment|length %}''
</code></pre>

<p>but that still shows for its children.</p>

CC BY-SA 3.0
2016-06-15T09:43:31.290Z
Is this being output inside a nav of your structure or on a structure entry page?
Luke Pearce
CC BY-SA 3.0
2016-06-15T13:11:59.443Z
Yes Luke this is basically a nav for a structure where I wan't to display something differently only when on one of the parents url.
julzmon
<conditional>
How do I show something only for a parent segment and not it's children?
# How do I show something only for a parent segment and not it's children?

(Asked by: username_0 on 2016-06-15)

How do I display something only for one of the parent Structure sections and not others or this sections children?
I was thinking of using
{% if craft.request.segment(2) == 'modules' and craft.request.lastSegment|length %}''

but that still shows for its children.

**Tags:** conditional
> **Comments:**
> **username_1**: Is this being output inside a nav of your structure or on a structure entry page?  
> **username_0**: Yes Luke this is basically a nav for a structure where I wan't to display something differently only when on one of the parents url.  

---

## 1 answers

### Answer by username_2 on 2016-06-15. Score: 2 | Accepted answer

The lastSegment will always have length whether it's 2, 3, 4 etc. I am unclear about your Structure setup, but if there is nothing after "modules", "modules" is the last segment and therefore exists.
So maybe something like:
{% if craft.request.getSegment(2) == 'modules' and not craft.request.getSegment(3)|length %}

> **Comments:**
> **username_0**: Thank you for setting me on the right track. I was able to accomplish what I wanted with the following. `{% if craft.request.getSegment(2) == 'modules' and not craft.request.getSegment(3)|length %}`  
> **username_2**: I added "not" to the answer above that I had originally left out.  

---

