I am trying to get my second level nav links to show up only when their parent is clicked. Right now, all second level nav links are layed out statically beneath their parent.
<!-- Input the documenttype you want here --> <!-- Typically '1' for topnavigtaion and '2' for 2nd level --> <!-- Use div elements around this macro combined with css --> <!-- for styling the navigation -->
Second Level Navigation - Quick Fix?
I am trying to get my second level nav links to show up only when their parent is clicked. Right now, all second level nav links are layed out statically beneath their parent.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Input the documenttype you want here -->
<!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
<!-- Use div elements around this macro combined with css -->
<!-- for styling the navigation -->
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<xsl:for-each select="umbraco.library:GetXmlNodeById(1045)/node [string(data [@alias='umbracoNaviHide']) != '1']">
<a href="{umbraco.library:NiceUrl(@id)}" class="navOff">
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">navOn</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">navOff</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@nodeName"/>
</a>
<!-- Secondary Nav -->
<xsl:if test="count(./child::node [string(data [@alias='umbracoNaviHide']) != '1']) > 0">
<ul>
<xsl:for-each select="./child::node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<!-- Secondary Nav -->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
add a check to your xsl:if for second nav if $currentPage equals the selected node (same test for your class)...?
Hi Joe
Try changing your xsl:if to this:
Does that help?
/Kim A
is working on a reply...