My question is related to this page... How can I add a dynamic "active" CSS class to the navigation on any given page?
Thank you in advance my code is the following:
<ul id="slide-in"> {% nav menu in craft.entries.section('mainMenu') %} <li class="{{ menu.id == entry.id ? 'active' }}"> <a href="{{ menu.menuLink[0].url }}">{{ menu.title }}</a> </li> {% endnav %} </ul> I am using Ben's code from this page but I am struggling to get this method working. I was wondering if someone could help me get to the bottom of this. I assume menu.id does not match entry.id and therefore the class is not added but how can I check the two id's are matching?
MenuID:{{ menu.id }} - EntryID:{{ entry.id }}