For some reason it shows the children to the item called 'Service menu' (id=1097) even though that umbracoNaviHide is set to 1, and all my selects include not(umbracoNaviHide = 1)
The other problem, is that, I only want the navigation to expand along the way, showing subpages the pages I've clicked.
Any ideas ?
The XML looks like this. The XSLT has been hijacked from here and modified a bit so it now looks like this.
<?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::Frontpage[@level = 1]" />
<xsl:template match="/">
<ul class="leftnavigation">
<!-- Start with children of the site root -->
<xsl:apply-templates select="$siteRoot/Subpage/Subpage[@isDoc and not(umbracoNaviHide = 1)]" />
</ul>
</xsl:template>
<xsl:template match="Subpage[@isDoc]">
<xsl:variable name="firstitem" select="'first '" />
<xsl:variable name="lastitem" select="'last '" />
<xsl:variable name="currentitem" select="'selected '" />
<xsl:variable name="classes">
<xsl:if test="position() = 1">
<xsl:value-of select="$firstitem"/>
</xsl:if>
<xsl:if test="position() = last()">
<xsl:value-of select="$lastitem"/>
</xsl:if>
<xsl:if test="@id = $currentPage/@id">
<xsl:value-of select="$currentitem"/>
</xsl:if>
</xsl:variable>
<li>
<xsl:if test="normalize-space($classes)">
<xsl:attribute name="class">
<xsl:value-of select="normalize-space($classes)" />
</xsl:attribute>
</xsl:if>
<a href="{umb:NiceUrl(@id)}">
<xsl:if test="$currentPage/ancestor-or-self::Subpage[@id = current()/@id]">
<xsl:attribute name="class">aktiv</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName" />
</a>
<!-- Make sure there is at least one visible page below, otherwise we get an empty <ul/> -->
<!-- If you need to stop at some level, do that here, like this: -->
<!-- <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)][not(level > 4)]"> -->
<xsl:if test="Subpage[@isDoc and not(umbracoNaviHide = 1)]">
<ul>
<xsl:apply-templates select="Subpage[@isDoc and not(umbracoNaviHide = 1)]" />
</ul>
</xsl:if>
</li>
</xsl:template>
<!-- This automatically hides items with umbracoNaviHide checked -->
<xsl:template match="Subpage[umbracoNaviHide = 1]" />
</xsl:stylesheet>
<!-- Make sure there is at least one visible page below, otherwise we get an empty <ul/> --> <!-- If you need to stop at some level, do that here, like this: --> <!-- <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)][not(level > 4)]"> --> <xsl:iftest="Subpage[@isDoc and not(umbracoNaviHide = 1)]"> <ul>
<!-- here you do a check for $currentPage/ancestor-or-self::Subpage/@id = @id -->
<xsl:if test="$currentPage/ancestor-or-self::Subpage/@id = @id">
<!-- sorry I have taken this off the top of mind -->
<xsl:apply-templatesselect="Subpage[@isDoc and not(umbracoNaviHide = 1)]"/>
</xsl:if>
</ul>
</xsl:if>
Expandable left navigation
I have 2 problems with this navigation ...
For some reason it shows the children to the item called 'Service menu' (id=1097) even though that umbracoNaviHide is set to 1, and all my selects include not(umbracoNaviHide = 1)
The other problem, is that, I only want the navigation to expand along the way, showing subpages the pages I've clicked.
Any ideas ?
The XML looks like this.
The XSLT has been hijacked from here and modified a bit so it now looks like this.
<?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::Frontpage[@level = 1]" /> <xsl:template match="/"> <ul class="leftnavigation"> <!-- Start with children of the site root --> <xsl:apply-templates select="$siteRoot/Subpage/Subpage[@isDoc and not(umbracoNaviHide = 1)]" /> </ul> </xsl:template> <xsl:template match="Subpage[@isDoc]"> <xsl:variable name="firstitem" select="'first '" /> <xsl:variable name="lastitem" select="'last '" /> <xsl:variable name="currentitem" select="'selected '" /> <xsl:variable name="classes"> <xsl:if test="position() = 1"> <xsl:value-of select="$firstitem"/> </xsl:if> <xsl:if test="position() = last()"> <xsl:value-of select="$lastitem"/> </xsl:if> <xsl:if test="@id = $currentPage/@id"> <xsl:value-of select="$currentitem"/> </xsl:if> </xsl:variable> <li> <xsl:if test="normalize-space($classes)"> <xsl:attribute name="class"> <xsl:value-of select="normalize-space($classes)" /> </xsl:attribute> </xsl:if> <a href="{umb:NiceUrl(@id)}"> <xsl:if test="$currentPage/ancestor-or-self::Subpage[@id = current()/@id]"> <xsl:attribute name="class">aktiv</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName" /> </a> <!-- Make sure there is at least one visible page below, otherwise we get an empty <ul/> --> <!-- If you need to stop at some level, do that here, like this: --> <!-- <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)][not(level > 4)]"> --> <xsl:if test="Subpage[@isDoc and not(umbracoNaviHide = 1)]"> <ul> <xsl:apply-templates select="Subpage[@isDoc and not(umbracoNaviHide = 1)]" /> </ul> </xsl:if> </li> </xsl:template> <!-- This automatically hides items with umbracoNaviHide checked --> <xsl:template match="Subpage[umbracoNaviHide = 1]" /> </xsl:stylesheet>excerpt
scott
Hi Sebastian,
The reason it shows the items below "Service menu" is because your select skips the umbracoNaviHide test on that level - compare:
To this:
/Chriztian
Thanx guys
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.