2

I have a simple nav tag

{% set navConfig = {
    'startwithActive' : true,
    'maxDepth' : 2,
    'activeClassOnAncestors' : true,
    'ancestorActiveClass' : 'active',
} %}
    {% nav node in navigation %}

      <li{% if node.class %} class="{{ node.class }}"{% endif %}>
        <a href="{{ node.link }}">{{ node.title }}</a>
        {% ifchildren %}
             <ul class="dropdown">{% children %}</ul>
        {% endifchildren %}
    </li>
{% endnav %}

This works fine all but with the News section entries. my-site/news adds the active class to the link, but my-site/news/new-entry doesn't add the class to the ancestor.

I have tried most configurations with the available parameters and variables, but I cannot work it out.

Any help would be brilliant!

2

I think what you want to look at is the Regular Expression option under the advanced tab for your my-site/news node. You could add something like:

 /^my-site\/news/i

This way all of the child pages in that section will mark the News page as active.

MW

| improve this answer | |
  • Thanks Michael, I would have never come up with that.... Could you elaborate what the activeClassOnAncestors : true, does differently? – Nutmeg Jan 5 '17 at 20:10

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.