Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    May 23, 2011 @ 15:56
    Anthony Candaele
    0

    xslt navigation

    Hi,

    I'm implementing a left navigation structure that should look like this:

     

    My content tree in the Umbraco backend looks like this:

    For the moment I'm trying to implement the activies node in the left navigation so I made an xslt file: LeftNavigationActivities.xslt

    the xslt looks like this:

    <div class="box_title">Activities</div>
        <div class="menu">
          <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li id="nav-seminars">
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
    </div>

    As you can see, I'm reading all nodes from level 3.

    The problem is that this script only works correct if I'm at a level 3 page. If I'm on a page that's higher in the hierarchy, like the homepage, the left navigation is empty.

    I suppose I should alter this bit: $currentPage/ancestor-or-self::* So that the nodes under the Activities nodes are read out, from wherever I'm am in the hierarchy, but I don't know how to do this.

    Does anyone know how to read nodes from a certain level in the hierarchie, no matter the hierarchy of the current page?

    Thanks for your help,

    Anthony Candaele
    Belgium

  • dimi309 245 posts 579 karma points
    May 23, 2011 @ 16:39
    dimi309
    0

    How about always going all the way to the top and then back down to level 3? Something like this:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level=1 and @isDoc]/descendant::*[@level=$level and @isDoc]/* [@isDoc and string(umbracoNaviHide) != '1']" >

     

    Dimitri


  • Anthony Candaele 1197 posts 2049 karma points
    May 23, 2011 @ 16:49
    Anthony Candaele
    0

    Hi Dimitri,

    I tried your suggestion, but now the left navigation menu under 'activities' shows all level 3 nodes (see screenshot)

    Only the 3rd level pages under the 'Activities' node should be listed.
    thanks for your help,
    Anthony
  • dimi309 245 posts 579 karma points
    May 23, 2011 @ 17:02
    dimi309
    0

    Hello Anthony,

    I am sorry for the sloppy suggestions but I don't have umbraco in front of me to actually try things out. Maybe this though?

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level=1 and @isDoc]/descendant::*[@level=$level and @isDoc]/child::* [@isDoc and string(umbracoNaviHide) != '1']>

     

    Dimitri

  • dimi309 245 posts 579 karma points
    May 23, 2011 @ 17:15
    dimi309
    0

    The other thing you could do if you are only interested in the nodes under Activities is to use specifically the activities id:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level=1 and @isDoc]/descendant::*[@id=(activities id, hardcoded) and @isDoc]/child::* [@isDoc and string(umbracoNaviHide) != '1']>

  • Anthony Candaele 1197 posts 2049 karma points
    May 23, 2011 @ 17:23
    Anthony Candaele
    0

    Hi Dimitri,

    the xslt-script seems to read the right level now, but it reads all level 3 nodes:

    This is what my Content tree in the Umbraco backend looks like (I changed the hierarchie)
    So as you see, nodes from the 3rd level are read, but from the Staff node (level 2). While only the level 3 nodes from the Activities node should be read:
    I appreciate your help,
    Anthony
  • dimi309 245 posts 579 karma points
    May 23, 2011 @ 17:29
    dimi309
    1

    Hi Anthony,

    How about passing in the activities id as a parameter and making something like this?

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level=1 and @isDoc]/descendant::*[@id=$id and @isDoc]/child::* [@isDoc and string(umbracoNaviHide) != '1']>

    Dimitri

  • Anthony Candaele 1197 posts 2049 karma points
    May 23, 2011 @ 17:38
    Anthony Candaele
    0

    Hi Dimitri,

    Yes!! This works.

    Thanks a lot.

    Anthony

  • dimi309 245 posts 579 karma points
    May 23, 2011 @ 18:30
    dimi309
    0

    No problem! Have a nice evening.

     

    Dimitri

Please Sign in or register to post replies

Write your reply to:

Draft