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 I'm a new umbraco developer, just getting to grips with it. I have created an xslt file to navigate 1 level.
I need to create an xslt to navigate from a top level navigation like this:
page 1 >
sub page 1 >
sub page 2 >
sub sub page 1 >
sub page 3 >
page 2 >
I could also use some advice on how to render it.
thanks for any help you can offer.
here is the XSLT i already have.
<!-- Root Node -->
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />
<!-- Homepage -->
<xsl:variable name="homeNode" select="$rootNode/Home [@isDoc]" />
<ul id="navi">
<li>
<!--
Add the CSS class 'selected' if the homeNode ID matches our
currentPage node ID
-->
<xsl:if test="$homeNode/@id = $currentPage/@id">
<xsl:attribute name="class">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
<!--Create a link to the homepage -->
<a href="{umbraco.library:NiceUrl($homeNode/@id)}">
<xsl:value-of select="$homeNode/@nodeName" />
</a>
</li>
For each child node of the homeNode that is a document (isDoc)
and the level is 2
and the property umbracoNaviHide is NOT 1 (true/checked)
<xsl:for-each select="$homeNode/* [@isDoc and @level = 2 and string(umbracoNaviHide) != '1']">
Add the CSS class 'selected' if the currentPage or parent nodes (up the tree to the root)
ID matches our current node's ID in the for each loop
<xsl:if test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
<!-- Create the link -->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
What exactly don't work ?
the xslt macro only lets me navigate the top layer of my content tree, im not sure how to get it to navigate lower levels of the content tree.
You should insert nested foreach in the main for-each.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
TopNavigation Multi-Layer
Hi I'm a new umbraco developer, just getting to grips with it. I have created an xslt file to navigate 1 level.
I need to create an xslt to navigate from a top level navigation like this:
page 1 >
sub page 1 >
sub page 2 >
sub sub page 1 >
sub page 3 >
page 2 >
I could also use some advice on how to render it.
thanks for any help you can offer.
here is the XSLT i already have.
<!-- Root Node -->
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />
<!-- Homepage -->
<xsl:variable name="homeNode" select="$rootNode/Home [@isDoc]" />
<ul id="navi">
<li>
<!--
Add the CSS class 'selected' if the homeNode ID matches our
currentPage node ID
-->
<xsl:if test="$homeNode/@id = $currentPage/@id">
<xsl:attribute name="class">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
<!--Create a link to the homepage -->
<a href="{umbraco.library:NiceUrl($homeNode/@id)}">
<xsl:value-of select="$homeNode/@nodeName" />
</a>
</li>
<!--
For each child node of the homeNode that is a document (isDoc)
and the level is 2
and the property umbracoNaviHide is NOT 1 (true/checked)
-->
<xsl:for-each select="$homeNode/* [@isDoc and @level = 2 and string(umbracoNaviHide) != '1']">
<li>
<!--
Add the CSS class 'selected' if the currentPage or parent nodes (up the tree to the root)
ID matches our current node's ID in the for each loop
-->
<xsl:if test="$currentPage/ancestor-or-self::* [@isDoc]/@id = current()/@id">
<xsl:attribute name="class">
<xsl:text>selected</xsl:text>
</xsl:attribute>
</xsl:if>
<!-- Create the link -->
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
What exactly don't work ?
the xslt macro only lets me navigate the top layer of my content tree, im not sure how to get it to navigate lower levels of the content tree.
You should insert nested foreach in the main for-each.
is working on a reply...