I'm using the RunawayTopNavigation.xslt with some modifications but it doesn't display the main node. My structure is like this: - Start (frontpage) - - Page 1 - - Page 2 - - Page 3
Currently it only displays
Page 1 | Page 2 | Page 3
But I want it to display the main node as well
Start | Page 1 | Page 2 | Page 3
From my xslt:
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level = $level]/* [string(umbracoNaviHide) != '1' and @isDoc]">
<xsl:choose>
<!-- Check if the page is an external link -->
<xsl:when test="externalLink = 1">
<li id="mnu_{@nodeTypeAlias}">
<a href="{link}" title="{@nodeName}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- It's not external link so let's check if it's the active page and set a new class -->
<xsl:when test="$currentPage/ancestor-or-self::root//@id = @id">
<li id="mnu_{@nodeTypeAlias}">
<a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}" class="active">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<!-- Not an external link or the active page, display it normal -->
<li id="mnu_{@nodeTypeAlias}">
<a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Another problem is that all menu items, except external get the class="active"
Problem 1: It's because the XSLT will only give you those nodes under the root node, in this case your start page. I'm not sure how to make an elegant solution to it, but a pragmatic approach could be to simply just hardcode the link to the startpage outside of the for-each loop. I've done this on some occasions.
Then you'll also save some writing, because you don't have to use that xsl:choose, when the only difference is the class on the li-tag, when the node is active.
That's because the XSLT does not know the value before runtime. So in this case you can safely check the "Skip error testing" checkbox when you save your XSLT.
Problem with RunawayTopNavigation.xslt
Hi,
I'm using the RunawayTopNavigation.xslt with some modifications but it doesn't display the main node.
My structure is like this:
- Start (frontpage)
- - Page 1
- - Page 2
- - Page 3
Currently it only displays
But I want it to display the main node as well
From my xslt:
Hi Anders
Problem 1: It's because the XSLT will only give you those nodes under the root node, in this case your start page. I'm not sure how to make an elegant solution to it, but a pragmatic approach could be to simply just hardcode the link to the startpage outside of the for-each loop. I've done this on some occasions.
Problem 2: Try altering this piece of code
to this instead
<xsl:when test="$currentPage/ancestor-or-self::*/@id = current()/@id">
Hope this helps
/Jan
Hi Anders
To get the main node as well, you can insert this piece of code just before the for-each:
/Kim A
Thanks Kim and Jan, that did the trick!
If I want to do the same thing in a submenu, so that the first node in the submenu is the parent node? How can I do that?
You can probably change your code to this:
Then you'll also save some writing, because you don't have to use that xsl:choose, when the only difference is the class on the li-tag, when the node is active.
/Kim A
thanks, but this: {umbraco.library:NiceUrl($subNode/@id)}
Gives me: System.OverflowException: Value was either too large or too small for an Int32.
Hi Anders
That's because the XSLT does not know the value before runtime. So in this case you can safely check the "Skip error testing" checkbox when you save your XSLT.
/Jan
is working on a reply...