Copied to clipboard

Flag this post as spam?

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


  • newbie 13 posts 33 karma points
    Feb 27, 2012 @ 20:53
    newbie
    0

    Including Parent node in 2nd level Navigation

    I wish to include the parent node within my navigation is this possible? at the moment i have it displaying all of the pages which are under that node however i wish the home node to be included.

    this is my code:

    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '2']">
      <li>
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="sectionNavigation"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    This is My Navigation:

    Home

    Section
    Pages
    Pages
    Pages
    Pages
    I want the navigation which is displayed in the "pages" navigation to also include "section" at the beginning.
    Is this possible?
    Thanks!


     

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Feb 28, 2012 @ 09:27
    Lee Kelleher
    1

    Hi newbie, (I'm sure you have a real name?)

    Easy way to do this is to set the homepage node as a separate variable, then we can re-use it within the xsl:for-each loop...

    <xsl:variable name="homepage" select="$currentPage/ancestor-or-self::*[@level = $level]" />
    <ul>
        <xsl:for-each select="$homepage | $homepage/*[@isDoc]">
            <li>
                <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="sectionNavigation"/>
                </a>
            </li>
        </xsl:for-each>
    </ul>

    Inside the xsl:for-each's select, we are using a pipe symbol to combine the node-sets.  So this would give you the homepage, then all the child nodes of the homepage.  (I removed the "umbracoNaviHide" stuff, as I assumed since you set the condition to "2", that you weren't using it anyway).

    Any questions, let me know.

    Cheers, Lee.

  • newbie 13 posts 33 karma points
    Feb 28, 2012 @ 18:24
    newbie
    0

    Hi Lee

    Oooooh i seee! This is really great thanks!

    wasnt sure before where you would call the homepage, but now i totally get it! 

    Thanks for your help! 

    Newbie :) 

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

Please Sign in or register to post replies