Copied to clipboard

Flag this post as spam?

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


  • dwarakesh 50 posts 69 karma points
    Sep 08, 2011 @ 11:13
    dwarakesh
    0

    Multi level navigation XSLT

    my node structure is like

    parent  node-
                   node1
                            - subnode1
                            - subnode2 
                   node2
                           - subnode3
                           - subnode4

    i have a  multi level navigation XSlt which produces menu like in the above structure. There is a part of that  XSlt which i dont understand.
      

     <xsl:if test="$currentPage/descendant::* [@level=1]">                   
                        <xsl:text>current</xsl:text>
                      </xsl:if>

    what is that @level   value for all the nodes whether it will ne different or same..

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 11:27
    Dirk De Grave
    0

    Hi dwarakesh,

    Each node in your content structure has a level property which is saved to the published xml as an attribute, hence the @level notation. Each top level node (child nodes of 'Content') have level = 1, child nodes of your top level nodes have level = 2 and so on

    in your case, if 'parent node' is a child node of 'Content', it will have a level = 1, node 1 and node 2 will have level = 2, ...

    Cheers,

    /Dirk

  • dwarakesh 50 posts 69 karma points
    Sep 08, 2011 @ 12:01
    dwarakesh
    0

    i m using the below xslt.. in that level 2 menus are not checked.. but i m getting above mentioned structure.. keeps me wondering ..

     

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

     
    <ul id="jsddm">

      <li>
           <xsl:attribute name="class">
             <xsl:if test="$currentPage/@level=$level">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
         

     </li>
     
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> 
      <li>
         <xsl:attribute name="class">
             <xsl:if test="$currentPage/@id=@id">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
       
       
        <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>   
        <!-- Drop Down Menu -->
        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
           <ul>
             <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
                 <li>
                  
                    <xsl:attribute name="class">
                       <xsl:if test="$currentPage/descendant::* [@level=1]">                   
                        <xsl:text>current</xsl:text>
                      </xsl:if>
                    </xsl:attribute>
                  
                   <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
             </xsl:for-each>
           </ul>
        </xsl:if>
      <!-- End of Drop Down Menu -->
       
      </li>
      </xsl:for-each>
      </ul>

    </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft