I have a sub-navigation XSLT which will output the sub-nodes of a parent - it doesn't need to be extremely flexible or generic, so we cut out the 'Home' node as irrelevant and, if one level under that just list the items under the current node, like so:
This works, so, the next step is to say that: if further down, say, @level=3, we want to list those same items (those of the parent in this case, but it would be an ancestor if @level=4), so:
This is why I always create a "siteRoot" variable for a fixed reference to the top - and base my navigations etc. off of that, e.g.:
<xsl:param name="currentPage" />
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
<!-- Select the Navigation root here, e.g. by ID or @nodeName or similar -->
<xsl:variable name="navRoot" select="$siteRoot/*[@id = 1800]" />
<xsl:template match="/">
<xsl:for-each select="$navRoot/*[@isDoc][not(umbracoNaviHide = 1)]">
<!-- etc. -->
</xsl:for-each>
</xsl:template>
Select nodes of ancestor at specific level
I have a sub-navigation XSLT which will output the sub-nodes of a parent - it doesn't need to be extremely flexible or generic, so we cut out the 'Home' node as irrelevant and, if one level under that just list the items under the current node, like so:
<xsl:when test="$currentPage/@level = 2">
<xsl:for-each select="$currentPage/* [@isDoc]">
This works, so, the next step is to say that: if further down, say, @level=3, we want to list those same items (those of the parent in this case, but it would be an ancestor if @level=4), so:
<xsl:when test="$currentPage/@level > 2">
<xsl:for-each select="$currentPage/ancestor/* [@level = 2]/* [@isDoc]">
I adapted source given in this post to attempt this, but to no avail.
Hi Grant,
This is why I always create a "siteRoot" variable for a fixed reference to the top - and base my navigations etc. off of that, e.g.:
/Chriztian
Try:
<xsl:when test="$currentPage/@level > 2">
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level = 2]/* [@isDoc]">
is working on a reply...