Creating vertical multilevel navigation for umbraco XSLT
I'm trying to create a vertical multilevel nav for Umbraco using
XSLT, that will add nested lists automatically. Currently I have had to
keep adding each nested list manually into the XSLT (which is not good
practice).
I've created the following menu but I need help as it's not creating the nest lists properly:
Creating vertical multilevel navigation for umbraco XSLT
I'm trying to create a vertical multilevel nav for Umbraco using XSLT, that will add nested lists automatically. Currently I have had to keep adding each nested list manually into the XSLT (which is not good practice).
I've created the following menu but I need help as it's not creating the nest lists properly:
Here's manual added nested lists XSLT:
Can anyone suggest a solution?
Hi JV,
This is one of the things XSLT's templates are awesome at - here's a very simple infinite levels navigation for you to build upon:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" exclude-result-prefixes="umb" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:param name="currentPage" /> <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" /> <xsl:template match="/"> <ul id="nav"> <xsl:apply-templates select="$siteRoot/*[@isDoc][not(umbracoNaviHide = 1)]" /> </ul> </xsl:template> <!-- Generic template for the links --> <xsl:template match="*[@isDoc]"> <!-- Grab the child nodes here (if any) --> <xsl:variable name="childNodes" select="*[@isDoc][not(umbracoNaviHide = 1)]" /> <li> <!-- Add class if any visible children --> <xsl:if test="$childNodes"><xsl:attribute name="class">selected</xsl:attribute></xsl:if> <a href="{umb:NiceUrl(@id)}" title="{@nodeName}"> <xsl:value-of select="@nodeName" /> </a> <xsl:if test="$childNodes"> <ul> <xsl:apply-templates select="$childNodes" /> </ul> </xsl:if> </li> </xsl:template> </xsl:stylesheet>/Chriztian
Thanks Chriztian,
I've made some edits, but I need to add a "current" CSS class. I tried using the following but it doesn't work:
jv,
take a log at my colleguaes package called flexible navigation there is xslt and razor versions http://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.