I've tried a number of different navigation XSLT scripts but I can't seem to get it working. I haven't used XSLT much but this mostly comes from somewhere else. The pages just don't appear in the site anywhere. Along with this script there is a Macro control in the master template and two fields in each page called Menu Name and Show In Menu. Any help would be greatly appreciated
<xsl:param name="currentPage"/> <xsl:variable name="maxLevelForSitemap" select="6"/> <!-- Request the value for siteRoot, and define it as a variable --> <xsl:variable name="siteRoot"> <xsl:value-of select="$currentPage/ancestor::root/node/@id"/> </xsl:variable> <xsl:template match="/"> <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/> </xsl:call-template> </xsl:template>
What version of Umbraco are you using? I'm asking since I can see the code is matching the old xml schema in Umbraco. It changed with the 4.5 release of Umbraco last year. So if you're using a 4.5 or newer version that's why it does not work.
Where do you have this code from? Have you found it as an example here on our or on a blogpost? Or have you created it yourself based on one of the predefined XSLT snippets?
Thanks for your reply but this problem I have just solved. The problem was the pages needed to be grouped into a folder for it to work I couldn't just keep the pages in the Content folder alone. Seems quite strange but moving them into a root folder has caused the navigation to work.
I do however have a different problem now. I cannot move my blog into the root folder it errors saying the folder cannot be moved due to its type. I'm using Blog4Umbraco as the blogging system. Any ideas on how I can get around this?
Navigation
I've tried a number of different navigation XSLT scripts but I can't seem to get it working. I haven't used XSLT much but this mostly comes from somewhere else. The pages just don't appear in the site anywhere. Along with this script there is a Macro control in the master template and two fields in each page called Menu Name and Show In Menu. Any help would be greatly appreciated
<?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="maxLevelForSitemap" select="6"/>
<!-- Request the value for siteRoot, and define it as a variable -->
<xsl:variable name="siteRoot">
<xsl:value-of select="$currentPage/ancestor::root/node/@id"/>
</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:for-each select="$parent/node [string(data [@alias = 'display_in_menu']) = '1']">
<li>
<xsl:choose>
<xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
<h3 class="active">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="data [@alias = 'Menu_Name']"/>
</a>
</h3>
</xsl:when>
<xsl:when test="$currentPage/ancestor-or-self::node/@id != current()/@id">
<h3>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="data [@alias = 'Menu_Name']"/>
</a>
</h3>
</xsl:when>
</xsl:choose>
<ul>
<xsl:call-template name="drawChildNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</ul>
</li>
</xsl:for-each>
</xsl:template>
<xsl:template name="drawChildNodes">
<xsl:param name="parent"/>
<xsl:for-each select="$parent/node">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="data [@alias = 'Menu_Name']"/>
</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Hi Steve
What version of Umbraco are you using? I'm asking since I can see the code is matching the old xml schema in Umbraco. It changed with the 4.5 release of Umbraco last year. So if you're using a 4.5 or newer version that's why it does not work.
Where do you have this code from? Have you found it as an example here on our or on a blogpost? Or have you created it yourself based on one of the predefined XSLT snippets?
/Jan
Hi Jan,
Thanks for your reply but this problem I have just solved. The problem was the pages needed to be grouped into a folder for it to work I couldn't just keep the pages in the Content folder alone. Seems quite strange but moving them into a root folder has caused the navigation to work.
I do however have a different problem now. I cannot move my blog into the root folder it errors saying the folder cannot be moved due to its type. I'm using Blog4Umbraco as the blogging system. Any ideas on how I can get around this?
is working on a reply...