If you take a look at http://www.markings.dk/produkter/macsa-laser.aspx And click at "Gummi" in the left menu, the left menu collapses, it shouldnt, the left menu should remain open, and "Gummi" should get the "Selected" class
Whilst iterating through the nodeset, we check for the "$currentPage/ancestor-or-self::node/@id = @id" XPath. If a parent node matches the ID, then it will add the "class=selected".
That should keep your menu structure expanded - based on your existing CSS.
Third level in menu disappears
Hey everyone...
If you take a look at http://www.markings.dk/produkter/macsa-laser.aspx
And click at "Gummi" in the left menu, the left menu collapses, it shouldnt, the left menu should remain open, and "Gummi" should get the "Selected" class
The XSLT that handles the menu is this:
<?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"/>
<xsl:param name="level" select="2"/>
<xsl:template match="/">
<div class="leftmenu">
<xsl:call-template name="menu">
<xsl:with-param name="level" select="$level"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="menu">
<xsl:param name="level"/>
<ul class="level_{@level}">
<xsl:if test="count($currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']) > '0'">
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<xsl:if test="$currentPage/@id = current()/@id">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="$currentPage/@id = current()/@id">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
<xsl:if test="count(current()/node [string(data [@alias='umbracoNaviHide']) != '1']) > '0'">
<xsl:call-template name="submenu">
<xsl:with-param name="level" select="$level+1"/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</xsl:if>
</ul>
</xsl:template>
<xsl:template name="submenu">
<xsl:param name="level"/>
<ul class="level_{@level}">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="$currentPage/@id = current()/@id">
<xsl:attribute name="class">Selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Hi Nicky,
The reason the third level menu is hidden is because of the way your CSS is handling it. The parent menu item needs to keep the "selected" class.
Here's an updated XSLT for you:
Cheers, Lee.
Great, thx alot :)
Ooops, forgot to explain the change, doh!
For the "class=selected" attribute, we include an extra condition:
Whilst iterating through the nodeset, we check for the "$currentPage/ancestor-or-self::node/@id = @id" XPath. If a parent node matches the ID, then it will add the "class=selected".
That should keep your menu structure expanded - based on your existing CSS.
Cheers, Lee.
Glad it worked Nicky, don't forget to mark the solution.
Cheers, Lee.
Yeah, works like a charm :) Thx again mate :)
is working on a reply...