I'm having some trouble figuring this out... I have a menu that starts from the 2nd level(node), shows all the childnodes(level 3)... These childnodes have their own childnodes, that again have childnodes. They become visible when the parent node is clicked...
I want the menu to expand all the way to the last childnode when a level 3 node is clicked. But only the active level 3 node. Any ideas how to do this?
You could try looking at my navigation package which does what you are describing. You can either use it as is or just look at the source code for inspiration ;-)
It has example CSS and some basic documentation to get you started.
I've tried looking at your navigation package, but it isn't doing what I'm looking for... It does almost the same thing as the xslt that I posted... and I want it to expand all the childnodes under the active level 3 node...
Expanding menu with many childnodes
Hi,
I'm having some trouble figuring this out... I have a menu that starts from the 2nd level(node), shows all the childnodes(level 3)... These childnodes have their own childnodes, that again have childnodes. They become visible when the parent node is clicked...
I want the menu to expand all the way to the last childnode when a level 3 node is clicked. But only the active level 3 node. Any ideas how to do this?
Thanks in advance
/Anette
Anette,
Please share your current xslt with us... makes it easier for us and you to learn/change
TIA,
/Dirk
Sorry... Here it is (How to format as code or whatever it's called?)
<?xml version="1.0" encoding="utf-8"?>
<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="html"/>
<xsl:param name="currentPage"/>
<xsl:variable name="maxLevel" select="5"/>
<xsl:template match="/">
<div id="navigationmenu">
<xsl:call-template name="drawNodes">
<xsl:with-param name="current" select="$currentPage/ancestor-or-self::node [@level=1]"/>
<xsl:with-param name="level" select="2"/>
<xsl:with-param name="openpage" select="$currentPage"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="current"/>
<xsl:param name="openpage"/>
<xsl:param name="level"/>
<xsl:param name="active">
<xsl:choose>
<xsl:when test="count($openpage/ancestor-or-self::node) > 0">
<xsl:call-template name="isInSubmenu">
<xsl:with-param name="list" select="$openpage/ancestor-or-self::node"/>
<xsl:with-param name="pos" select="1"/>
<xsl:with-param name="curpagename" select="$current/@id"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
1
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:if test="$active=1">
<ul>
<xsl:if test="$level = 1">
<li>
<a href="/" class="menu_level1">
<xsl:value-of select="$current/@nodeName"/>
</a>
</li>
</xsl:if>
<xsl:for-each select="$current/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li>
<xsl:choose>
<xsl:when test="@id=$openpage/@id">
<a href="{umbraco.library:NiceUrl(@id)}" class="selected">
<xsl:value-of select="@nodeName"/>
</a>
</xsl:when>
<xsl:otherwise>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="@level = '3'">
<xsl:attribute name="class">
<xsl:text>menu</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="drawNodes">
<xsl:with-param name="current" select="."/>
<xsl:with-param name="openpage" select="$openpage"/>
<xsl:with-param name="level" select="$level + 1"/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<xsl:template name="isInSubmenu">
<xsl:param name="list"/>
<xsl:param name="pos"/>
<xsl:param name="curpagename"/>
<xsl:variable name="curitemname" select="$list[$pos]/@id"/>
<xsl:choose>
<xsl:when test="$curitemname != $curpagename">
<xsl:choose>
<xsl:when test="$pos < count($list)">
<xsl:call-template name="isInSubmenu">
<xsl:with-param name="list" select="$list"/>
<xsl:with-param name="pos" select="$pos + 1"/>
<xsl:with-param name="curpagename" select="$curpagename"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
0
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
1
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Hi Anette,
You could try looking at my navigation package which does what you are describing. You can either use it as is or just look at the source code for inspiration ;-)
It has example CSS and some basic documentation to get you started.
http://our.umbraco.org/projects/cogworks---flexible-navigation
T
Hi Tim,
I've tried looking at your navigation package, but it isn't doing what I'm looking for... It does almost the same thing as the xslt that I posted... and I want it to expand all the childnodes under the active level 3 node...
/Anette
is working on a reply...