im using umbraco for a while now and its really good but i just dont understand one thing.. how do you make a submenu? i found out that the sitemap xslt would work the best and it does but now i have to make a dropdown menu outof it. so for my css i wanted to give the ul that is going to be the submenu a class as a name but after trying several things.. it didnt give the ul the class name. what did i do wrong?..
i did no changes .. just the plain sitemap xslt. i now need to make a choose that looks if the level is 2(thats the base level because the website is in a folder) and if it is higher it should give the class="under" to the ul
can someone help me with this? i have looked everywhere but i can't find it!
i got a litle further with a css that i found. It makes the dropdown menu's but i got stuck with the way the sitemap formats the html code. (i dont need to give the ul's a name anymore now so that question is irrelevant now)
I made a for each loop inside my otherwise that did the same as the standard sitemap xslt and it did the trick with my previous css. it works with multiple sub menus =]
it seems that my xml makes the ul for the dropdown everytime he sees an subpage.. so it doesnt work correctly yet...
i was hoping i had the solution but it doesnt work as i hoped.. with the css you won't see the duplicate submenu, but it is there. is there some way i can just call the template one time in the loop and not every time he sees a subpage?
Stef
Edit:
I fixed the duplicates via adding a template that just uses the code once.
Sorry for spamming this much! I just wanted to share because i see alot of people with the same problem.
this xslt works with the following tree structure in your content btw:
content -WebsiteFolder (is used just as a containing folder because i am working with mutliple sites) --WebsiteDutch ---Page1 ----SubPage1 --WebsiteGerman ---Page1
----SubPage1 --WebsiteEnglish ---Page1
----SubPage1
so thats why the level is 3 in the test and that the parent isnt 1 but greater or equal to 1 (you have to set the webiste homepages like websitedutch and websitegerman true with the variable umbracoNaviHide to hide those)
how do i make a drop down menu with sitemap?
hey guys!
im using umbraco for a while now and its really good but i just dont understand one thing..
how do you make a submenu? i found out that the sitemap xslt would work the best and it does but now i have to make a dropdown menu outof it. so for my css i wanted to give the ul that is going to be the submenu a class as a name but after trying several things.. it didnt give the ul the class name. what did i do wrong?..
this is my xslt:
------------------------------------------------------------------------------------------------------------------------------------------------
<?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<!-- update this variable on how deep your site map should be -->
<xsl:variable name="maxLevelForSitemap" select="4"/>
<xsl:template match="/">
<div id="sitemap">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::* [@isDoc and @level=1]"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<ul><xsl:for-each select="$parent/* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/></a>
<xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
-------------------------------------------------------------------------------------------------------------------------------------------------
i did no changes .. just the plain sitemap xslt. i now need to make a choose that looks if the level is 2(thats the base level because the website is in a folder) and if it is higher it should give the class="under" to the ul
can someone help me with this? i have looked everywhere but i can't find it!
Thanks in advance,
Stef
i got a litle further with a css that i found. It makes the dropdown menu's but i got stuck with the way the sitemap formats the html code. (i dont need to give the ul's a name anymore now so that question is irrelevant now)
i now get this list structure:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This isn't what i want... i want the output to be like the following:
<div id="menu">
<ul>
<a>hello</a>
<ul>
<li>
<a>2nd link</a>
</li>
</ul>
</ul>
<ul>
<ul>
</div>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
so i would like to have the first (top) menu items to be a ul.. but i cant get this with my xml as it is now.
my css is like this for people who are interested:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
so.. if some1 knows what to edit or how to make it work.. i would be very thankfull!
Stef
found a solution!!
I made a for each loop inside my otherwise that did the same as the standard sitemap xslt and it did the trick with my previous css. it works with multiple sub menus =]
my xslt sceme looks like this at the moment:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
its a bit messy now.. but i guess you can figure it out. if you dont get a part of my xslt, just ask and ill explain it!
Stef
it seems that my xml makes the ul for the dropdown everytime he sees an subpage.. so it doesnt work correctly yet...
i was hoping i had the solution but it doesnt work as i hoped.. with the css you won't see the duplicate submenu, but it is there. is there some way i can just call the template one time in the loop and not every time he sees a subpage?
Stef
Edit:
I fixed the duplicates via adding a template that just uses the code once.
it looks like this now:
------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
Sorry for spamming this much! I just wanted to share because i see alot of people with the same problem.
this xslt works with the following tree structure in your content btw:
content
-WebsiteFolder (is used just as a containing folder because i am working with mutliple sites)
--WebsiteDutch
---Page1
----SubPage1
--WebsiteGerman
---Page1
----SubPage1
--WebsiteEnglish
---Page1
----SubPage1
so thats why the level is 3 in the test and that the parent isnt 1 but greater or equal to 1 (you have to set the webiste homepages like websitedutch and websitegerman true with the variable umbracoNaviHide to hide those)
Stef
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:map="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"
exclude-result-prefixes="map">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="map:siteMapNode">
<li>
<a href="{@url}" title="{@title}">
<span class="icon">
<img src="../Images/Icons/application_double.png" alt="NA" />
</span>
<span>
<xsl:value-of select="@title"/>
</span>
</a>
<xsl:if test="map:siteMapNode">
<ul id="SubMenu">
<xsl:call-template name="mapNode"/>
</ul>
</xsl:if>
</li>
</xsl:template>
<xsl:template name="mapNode" match="/*/*">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
This will take care of nested list view. It is the simple one I could have posted for you. Hope it will help.
is working on a reply...