Copied to clipboard

Flag this post as spam?

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


  • Sam 63 posts 126 karma points
    Apr 20, 2012 @ 11:44
    Sam
    0

    Show sub nav depending on level

    Hi all maybe someone can help me with this:

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="3"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <div id="navSubMnu">  
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <href="{umbraco.library:NiceUrl(@id)}">
                              <xsl:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
                                    <xsl:attribute name="class">current</xsl:attribute>
                                  </xsl:if>
                               <xsl:attribute name="href">
                                 <xsl:choose>
                                  <xsl:when test="count(./*[@isDoc]) &gt; 1  and string(linkToSubpage) = '1'">
                                       <xsl:value-of select="umbraco.library:NiceUrl(./*[@isDoc]/@id)" />
                                     </xsl:when>           
                                      <xsl:otherwise>
                                         <xsl:value-of select="umbraco.library:NiceUrl(@id)" />
                                      </xsl:otherwise>           
                                 </xsl:choose>
                              </xsl:attribute>
                             <xsl:value-of select="@nodeName"/>
        </a>
        
        
      </li>
      
      
    </xsl:for-each>
    </ul>
        </div>
      
     
      
    </xsl:template>

     

    Already have this xslt to show menu at level 3 when at level 3:

    en
       - Page A ( Level 1 ) 
           - Sub Page A ( Level 2 ) 
               - Sub Sub Page A 1 (Level 3)
               - Sub Sub Page A 2 (Level 3)
        - Page B ( Level 1 ) 
           - Sub Page B ( Level 2 ) 
           - Sub Page B ( Level 2 ) 


    But some pages have only 2 levels and I want to show the sub nav also..

    So what I want to do is depending on what level you are 2, 3, or maybe 4 show the sub navs on  those levels.

    Any advice

    //Sam

     

     


  • Sam 63 posts 126 karma points
    Apr 20, 2012 @ 13:42
    Sam
    0

    No one?

  • Sam 63 posts 126 karma points
    Apr 24, 2012 @ 09:53
    Sam
    0

    Please

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 24, 2012 @ 10:27
    Fuji Kusaka
    0

    Hi Sam,

    Try this, it should get you working. What you need to do here is to test if [@isDoc] is present just like you would with any navigation. 

     <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]"
                       <xsl:for-each select="./* [@isDoc  and string(umbracoNaviHide) != '1']">                           
                               <xsl:value-of select="@nodeName" />   
                      </xsl:for-each              
                </xsl:if>

    Add this line just after your <LI>

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft