I have a navigation like this:
{% set navi = craft.entries.id('2, 4, 5, 6' ).order('id asc') %}
<nav>
<ul>
{% for entry in navi %}
<li><a href="{{ entry.url }}" {% if entry.url == craft.request.geturl %}class="active"{% endif %}>{{ entry.naviTitel }}</a></li>
{% endfor %}
</ul>
</nav>
This results in something like:
- Home
- Projects
- About
- Contact
Now under Projects (Wich is a Single entry) are entry pages like this:
- url/projects/project_entry_1
- url/projects/project_entry_2
Now what I'm trying to achieve is that when viewing a project_entry, the nav link "Project" should have the class active which is not the case right now. Is this somehow possible with this navi markup or do I have to write something like this.
I taught about writing a conditional {% if url_segment 2 == project %} but that doesn't work because this would give all links the class active and since I have a multi-language installation segment_2 is not always the single slug.
What is the prettiest way to achieve this?
Thank you.
{{ segment ~ ' == ' ~ enSlug ~ ' == ' ~ deSlug }}??anywhere within your loop to find the problem! – carlcs Aug 13 '14 at 18:14Unexpected token "name" of value "segment" ("end of print statement" expected)on the line of the if statement. – KSPR Aug 13 '14 at 18:24{{ activeClass ? activeClass }}only works inside the if statement. When outside I getVariable "activeClass" does not exist– KSPR Aug 13 '14 at 18:58