Been working on the following xslt, which is generating the menu correctly. The next step is to add a current class, to the <a> tag of the parent <li> of the nested <ul> which contains the the current page.
Home - Level 2 - If nested <ul> contains current page, set <a> tag class of this <li> to current - Level 3 page - Level 3 page - current page - Level 3 page
Actually, you don't need to traverse up the tree, but instead you check if the branch you're on contains $currentPage:
<li class="{Exslt.ExsltStrings:lowercase(umbraco.library:Replace(@nodeName, ' ', ''))}">
<a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
<!-- Check if currentPage is somewhere below this -->
<xsl:if test="descendant::node[@id = $currentPage/@id]">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
...
</li>
Note also, that I've collapsed the generation of the title attribute - you don't need to use <xsl:attribute> for the simple title attributes you're creating.
Traverse up tree to add class
Hi All
Been working on the following xslt, which is generating the menu correctly. The next step is to add a current class, to the <a> tag of the parent <li> of the nested <ul> which contains the the current page.
Home
- Level 2 - If nested <ul> contains current page, set <a> tag class of this <li> to current
- Level 3 page
- Level 3 page - current page
- Level 3 page
Not sure how to traverse back up the tree, any help would be appericated.
Working with Umbraco 4.0.4.2
Thanks
Eddie
Hi Eddie,
Actually, you don't need to traverse up the tree, but instead you check if the branch you're on contains $currentPage:
Note also, that I've collapsed the generation of the title attribute - you don't need to use <xsl:attribute> for the simple title attributes you're creating.
/Chriztian
Hi Chriztian
Your a star, and a thanks for the tips.
Eddie
is working on a reply...