I have tried to google it and searched it on the forum, but i can't find a solution for the following problem:
I want to have a current state (class) on a parent node item in a navigation when a childnode is selected. I've tried it with the following code, but no succes.
The navigation is 3 nodes deep with a drop down menu so I want to have the current state(class) on the highest node in the navigation. Can somebody help me on this one? Thank you.
That doesn't do the trick, the change you've made is only effecting the current page. So when "item 1" is selected the current class is showing (that's good), but I want the current state is also showing when a child of "item 1" is active/selected.
Oh ok i see, from what you mentioned earlier you have a dropdown menu right? So when you click on any of the items displayed in the dropDown menu you want this item to have a current class as well??
The menu is a jquery dropdown menu, so when I rollover, the childs appear. When I click a childnode from the dropdown, the parent node must get the current state. So you can see under which categorie the child is selected/placed.
Change the first test (@id = $currentPage/@id) to this, and you'll get your "current" class applied if the selected page is below (or the same as) the one being rendered:
Navigation: Current state on parent node
I have tried to google it and searched it on the forum, but i can't find a solution for the following problem:
I want to have a current state (class) on a parent node item in a navigation when a childnode is selected. I've tried it with the following code, but no succes.
The navigation is 3 nodes deep with a drop down menu so I want to have the current state(class) on the highest node in the navigation. Can somebody help me on this one? Thank you.
Hi Niels,
You could try chaging this
to this
//fuji
Fuji,
That doesn't do the trick, the change you've made is only effecting the current page. So when "item 1" is selected the current class is showing (that's good), but I want the current state is also showing when a child of "item 1" is active/selected.
Oh ok i see, from what you mentioned earlier you have a dropdown menu right? So when you click on any of the items displayed in the dropDown menu you want this item to have a current class as well??
Niels what happens when you do this
The menu is a jquery dropdown menu, so when I rollover, the childs appear. When I click a childnode from the dropdown, the parent node must get the current state. So you can see under which categorie the child is selected/placed.
If i have understood you correctly this shoud work.
<xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:if>
put it under the li tag you want to put the class on.
Hi Niels,
Change the first test (@id = $currentPage/@id) to this, and you'll get your "current" class applied if the selected page is below (or the same as) the one being rendered:
/Chriztian
Hi Chriztian,
I was blinded by code but my eyes are open now ;-) Thank you for this simple but perfect solution!
Niels
thanks from me to...just what i was looking for!
S
is working on a reply...