Copied to clipboard

Flag this post as spam?

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


  • ds 191 posts 223 karma points
    Sep 03, 2010 @ 10:11
    ds
    0

    How to add root node to navigation

    Hi all,

    I am using version 4.5.2 and faced with a little problem. Probably it is quite easy but so far could not find any solution on umbraco forum.

    I have such structure 

    - Homepage

    - Gallery

    - Contact

    What I need to display homepage node in navigation with gallery and contact. Now only gallery and contact nodes are displayed

    and here is my xslt 

    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

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

    </xsl:template>

     

    thanx

  • Rich Green 2246 posts 4008 karma points
    Sep 03, 2010 @ 11:58
    Rich Green
    0

    Not tested but this should work

      <xsl:variable name="level" select="1"/>
    
    <xsl:template match="/">
    
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
    
     <li>
          <a href="/">     
             <xsl:value-of select="$currentPage/ancestor-or-self::*/@nodeName"/>
          </a>  
    </li>
    
     <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
    
    </xsl:template>
    
    Rich
  • Thomas Höhler 1237 posts 1709 karma points MVP
    Sep 03, 2010 @ 11:58
    Thomas Höhler
    0

    Try soething like this:

    Snippet

    <xsl:variable name="level" select="1"/>

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

    </xsl:template>

    hth, Thomas

  • Rich Green 2246 posts 4008 karma points
    Sep 03, 2010 @ 12:07
    Rich Green
    0

    Adjusted code for my solution (or use Thomas's code)

    I had the 'Home' node in the loop by mistake

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

     

    Rich

  • ds 191 posts 223 karma points
    Sep 03, 2010 @ 13:00
    ds
    0

    Thanks Rich and Thomas for valuable help.

Please Sign in or register to post replies

Write your reply to:

Draft