Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, everyone
I have code of 4 level-menu:
<?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:template match="/">
<!-- The fun starts here -->
<div id = "panel">
<ul class="dropdown" id="menu">
<!-- checking every node in navigation -->
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li class="static">
<div class="centerMenu">
<div class="liSpn">
<xsl:value-of select="@nodeName"/>
</div>
<!--*********************************** if current node have level 2 items, insert UL ***********************************-->
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat">
<xsl:if test="current()/@level = 2 and child::node()[*] !=''">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
</a>
<!--*********************************** if current node have level 3 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 3 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<!--*********************************** if current node have level 4 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 4 and child::node()[*] !=''">
</li>
</xsl:when>
<xsl:otherwise>
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
</xsl:otherwise>
</xsl:choose>
<li class="submenu1">
</xsl:for-each>
</ul>
</xsl:if>
<li style="background-image:url(/media/78975/lastEl.png);background-repeat:no-repeat;margin:0px;padding:0px;color:White;height:45px;width:90px;" id="col6">
<span class="liSpn"></span>
</xsl:template>
</xsl:stylesheet>
With this code here is what I get:
But I need:
Can someone help to find mistake?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Problem with 4 level menu
Hi, everyone
I have code of 4 level-menu:
<?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:template match="/">
<!-- The fun starts here -->
<div id = "panel">
<ul class="dropdown" id="menu">
<!-- checking every node in navigation -->
<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(data [@alias='umbracoNaviHide']) != '1']">
<li class="static">
<div class="centerMenu">
<div class="liSpn">
<xsl:value-of select="@nodeName"/>
</div>
</div>
<!--*********************************** if current node have level 2 items, insert UL ***********************************-->
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat">
<xsl:if test="current()/@level = 2 and child::node()[*] !=''">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 3 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 3 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 4 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 4 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 4 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 4 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 3 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 3 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 4 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 4 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<!--*********************************** if current node have level 4 items, insert UL ************************************ -->
<xsl:if test="current()/@level = 4 and child::node()[*] !=''">
<ul style="background:url(/media/79999/submenu.png) 0 0 no-repeat; border-left: solid 1px white; margin-top:-1px;">
<xsl:for-each select="current()/node [string(data [@alias='umbracoNaviHide']) != '1']">
<xsl:choose>
<xsl:when test="current()/child::node()[*] !=''">
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(current()/@nodeName) > 20">
<li class="submenu1">
<a class="longA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="submenu1">
<a class="liA" href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</ul>
</li>
</xsl:for-each>
<li style="background-image:url(/media/78975/lastEl.png);background-repeat:no-repeat;margin:0px;padding:0px;color:White;height:45px;width:90px;" id="col6">
<span class="liSpn"></span>
</li>
</ul>
</div>
</xsl:template>
</xsl:stylesheet>
With this code here is what I get:
But I need:
Can someone help to find mistake?
is working on a reply...