Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Isis 21 posts 42 karma points
    Feb 21, 2012 @ 12:47

    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 &gt; 2">
       <xsl:for-each select="$currentPage/ancestor/* [@level = 2]/* [@isDoc]"

    I adapted source given in this post to attempt this, but to no avail.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Feb 21, 2012 @ 13:00
    Chriztian Steinmeier

    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.:

    <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. -->


  • Ernst Utvik 123 posts 235 karma points
    Feb 23, 2012 @ 21:34
    Ernst Utvik


     <xsl:when test="$currentPage/@level &gt; 2">
       <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = 2]/* [@isDoc]">

Please Sign in or register to post replies

Write your reply to: