Someone built my site for me so I am scared $#!^less about making changes. So far I have been successful thanks to you. To try out things I use a local copy of CWS. My site was based from CWS.
I am trying to add a dropdown menu to my navigation bar but the way it was built there is no level below the first level (home is in the nav bar which I want). The "tab" at the page I am at is highlighted. The xslt code calling the structured list is :
<?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="/">
<ul>
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::node [@level=1]" />
<li>
<!--
Add the class selected if the root node ID matches our
current node ID in the for each loop
-->
<xsl:if test="$rootNode/@id = $currentPage/@id">
<xsl:attribute name="class">
<xsl:text>
selected
</xsl:text>
</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl($rootNode/@id)}">
<xsl:value-of select="$rootNode/@nodeName" />
</a>
</li>
<xsl:for-each select="$currentPage/ancestor-or-self::node/node [@level = 2 and string(data[@alias='umbracoNaviHide']) != '1']">
<li>
<!--
Add the class selected if the currentpage or parent nodes (up the tree to the root)
ID matches our current node ID in the for each loop
-->
<xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<xsl:attribute name="class">
<xsl:text>
selected
</xsl:text>
</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Now I have tried hard to replicate that in CWS but in vain. The solution would be to use sitemap (I could manage) but when I test that in the local copy it does not include the home button.
My questions are 1) can I use the xslt to drill down one level? 2) how can I get the home button in the sitemap (umbracoNavihide is unchecked).
<li> <!-- Add the class selected if the root node ID matches our current node ID in the for each loop --> <xsl:iftest="$rootNode/@id = $currentPage/@id"> <xsl:attributename="class"> <xsl:text> selected </xsl:text> </xsl:attribute> </xsl:if>
Add level to structured navigation menu from xslt
Hello,
Someone built my site for me so I am scared $#!^less about making changes. So far I have been successful thanks to you. To try out things I use a local copy of CWS. My site was based from CWS.
I am trying to add a dropdown menu to my navigation bar but the way it was built there is no level below the first level (home is in the nav bar which I want). The "tab" at the page I am at is highlighted. The xslt code calling the structured list is :
Now I have tried hard to replicate that in CWS but in vain. The solution would be to use sitemap (I could manage) but when I test that in the local copy it does not include the home button.
My questions are 1) can I use the xslt to drill down one level? 2) how can I get the home button in the sitemap (umbracoNavihide is unchecked).
Thanks in advance for your help.
Christophe
To drill down another level inside your 'li' add this code:
To include a link to your home button it looks like you already had the code:
is working on a reply...