At the moment it correctly applies a class of 'active' to a selected list item, but it doesn't apply that class to the first level list when you get into the second level. What I want to do is to keep the class of 'active' in the li tag of the top level of nav when it's sub-nav is selected.
basically it's changing the test for "is the id of the link to the current list item also the current page id?" to "is the id of this page also the id of this item in the nav, or its parent's?"
Add class to first level nav when second level nav selected
Hi,
Forgive all my XSLT questions today, I'm working on some navigation...
I have a two-level nested list navigation system, which works great using the code below:
At the moment it correctly applies a class of 'active' to a selected list item, but it doesn't apply that class to the first level list when you get into the second level. What I want to do is to keep the class of 'active' in the li tag of the top level of nav when it's sub-nav is selected.
Does anyone know how to achieve this?
Thanks folks...
Hi again!
Try this
basically it's changing the test for "is the id of the link to the current list item also the current page id?" to "is the id of this page also the id of this item in the nav, or its parent's?"
Absolutely perfect! Thanks again Dan - you're a gent.
For me this worked: <xsl:if test="$currentPage/ancestor-or-self::* [@level=2]/@id = @id">
is working on a reply...