Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hey guys,
So I know couch has a way to add an active class to the current menu link... However, I generally use a small jQuery snippet via a conditional: if this.href == window.location.href, add an active class to some <a> tag and its parents (if it's a nested menu)...
This snippet doesn't work anymore after activating pretty urls..

So I decided to try the couch way of doing things.. Please note that the client does not need to change things around in the menu, so there's no requirement for that in the CMS. From the blog tutorial, I used the code like this: <li><a href="<cms:link 'about-ithickal.php' />" <cms:if k_template_name=='about-ithickal.php'>class="nav-active"</cms:if>>About Ithickal</a></li>
The above code works, unless the menu is a nested menu.

The issue is that this is a click menu, so I need the active class to show on a parent li tag of the active menu link as well (i.e. the parent li has no url, but only reveals the dropdown menu on click). Is this a way to do this?
Hi imohkay,

Firstly - your JS solution should really work even with the prettyURLs. I think if we delve into the problem a little more we can find what is going wrong. If you wish, you can send me the version that was working and I'll take a look at it.

Next, if however you wish to use the Couch method -
I need the active class to show on a parent li tag of the active menu link as well (i.e. the parent li has no url, but only reveals the dropdown menu on click)
The <cms:if k_template_name=='about-ithickal.php'> check that you placed does not make use of the href (url) attribute at all.
The k_template_name variable will be set by Couch to 'about-ithickal.php' when the page being visited is 'about-ithickal.php' so you can check for this at any place in the entire template - even within the LI.

So, I think, the following should work as well -
Code: Select all
<li <cms:if k_template_name=='about-ithickal.php'>class="nav-active"</cms:if>>
   ... same check in <A href>..
</li>

If, for some reason, this does not work for you, please PM me your template's code and we'll work out how to handle the issue.

Hope this helps.
2 posts Page 1 of 1
cron