<a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> <!-- Drop Down Menu --> <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) > 0"> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <xsl:if test="$currentPage/descendant::* [@level=1]"> <xsl:attribute name="class">
<xsl:text>current</xsl:text>
</xsl:attribute> </xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}" > <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:if> <!-- End of Drop Down Menu -->
<a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> <!-- Drop Down Menu --> <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) > 0"> <ul> <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']"> <li> <a href="{umbraco.library:NiceUrl(@id)}" > <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> </ul> </xsl:if> <!-- End of Drop Down Menu -->
Adding classes to xslt menu
Hi,
This is my XSLT top navigation menu
<xsl:template match="/">
<xsl:variable name="level" select="1"/>
<xsl:variable name="dropDown" select="2"/>
<!-- The fun starts here -->
<ul id="menyn">
<li >
<xsl:attribute name="class">
<xsl:if test="$currentPage/@level=$level">
<xsl:text>current</xsl:text>
</xsl:if>
</xsl:attribute>
<a href="/">
<xsl:value-of select="$currentPage/ancestor-or-self::*/@nodeName"/>
</a>
</li>
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1'][not(self::RF-Slide)]">
<li >
<xsl:attribute name="class">
<xsl:if test="$currentPage/@id=@id">
<xsl:text>current</xsl:text>
</xsl:if>
</xsl:attribute>
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
<!-- Drop Down Menu -->
<xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) > 0">
<ul>
<xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:attribute name="class">
<xsl:if test="$currentPage/descendant::* [@level=1]">
<xsl:text>current</xsl:text>
</xsl:if>
</xsl:attribute>
<a href="{umbraco.library:NiceUrl(@id)}" ><xsl:value-of select="@nodeName"/></a></li>
</xsl:for-each>
</ul>
</xsl:if>
<!-- End of Drop Down Menu -->
</li>
</xsl:for-each>
</ul>
</xsl:template>
<!-- Never output these -->
<xsl:template match="*[umbracoNaviHide = 1]" />
It generates a menu with drop down.I need to add a css clsss name to <li> tag.Currently it doesnt genrate a class.Here is the illustration whatI need
<ul id="menyn">
<li class="current">
<a href="/" class="Need-A-Class-Name-Here>Home</a>
</li>
<li class="Need-A-Class-Name-Here">
<a href="/page.aspx">about</a>
<ul>
Thanks
Hi Shiraj,
Try this one. I have moved the attribute inside the if statement.
/Dennis
Hi Dennis,
Thanks for the answer but its not adding the class.It looks like this now.It doenst have class names for li and a
Hi,
Ok so what you want is this:
Right or is it all the a tags that has to have a class?
Looking forward to hear from you
/Dennis
Thanks Dennis you are allwyas helping me :)
I actually need to implement this menu
http://cssmenumaker.com/menu/opera-drop-down-menu
and ul list like this
<ul>
<li><a href='#'><span>Home</span></a></li>
<li class='has-sub '><a href='#'><span>Products</span></a>
<ul>
<li class='has-sub '><a href='#'><span>Product 1</span></a>
<ul>
<li><a href='#'><span>Sub Product</span></a></li>
<li><a href='#'><span>Sub Product</span></a></li>
</ul>
</li>
<li class='has-sub '><a href='#'><span>Product 2</span></a>
<ul>
<li><a href='#'><span>Sub Product</span></a></li>
<li><a href='#'><span>Sub Product</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>About</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
So I need to know how can I add class to li like this <li class='has-sub '>
and in any case if I need to add a class for a tag (optional)
Thanks
From the top of my mind I think this should do it for you, but I havn´t tested it
/Dennis
Thansk Dennis,
Here how shows now.How can we remove this " 
"
Okay is it correct that about page has subpages?
Try to make the attribute like this in one line. then the 
 should go away from your markup
/Dennis
Hi Dennis,
Sorry for the late reply but its working :)
Thanks again
Okay glad that I could help.
I think you should mark this as solved, so others with the same or similar issue can see what's work for you.
/Dennis
Done :)
is working on a reply...