1

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.

  • Is this being output inside a nav of your structure or on a structure entry page? – Luke Pearce Jun 15 '16 at 9:43
  • 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 Jun 15 '16 at 13:11
2

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 %}
| improve this answer | |
  • 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 Jun 15 '16 at 13:12
  • I added "not" to the answer above that I had originally left out. – AbbeyDesign Jun 16 '16 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.