Copied to clipboard

Flag this post as spam?

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


  • Jonas Gunnarsson 44 posts 194 karma points
    Nov 29, 2011 @ 20:18
    Jonas Gunnarsson
    0

    Help with xslt in a drop down menu

    Hi,
    I have a new umbraco v 4.7.1 (Assembly version: 1.0.4281.20201) installation, with uBlogsy package installed. It works great! I use the blog for my photgrapy business and my plan is to create a document type for my portfolio and I want to have a dropdown menu for this, it would be greate to have this for the archive as well. 
    I´m pretty new to umbraco but I have god skills in html/css and .net, but my XSLT-skills is rather low, and I have a solution that works for the drop down part but I need help with my xslt.
    This is the tree node in umbraco
    My blog (Home)
    Blog
     -2011
       -- January
       -- February
       -- and so on...
    Pages
     - About
     - Contact
     - Portfolio
      -- Portrait
      -- Children
      -- and so on..
    And this how I want it
    Home
    Archive
     - November 2011 (this month)
     - October 2011
     - and so on..
     - 2010
     -- December 2010
     -- November 2010
     -- and so on
      About
      Contact
     Portfolio
      - Portrait
      - Children
      - and so on..
    This is how my xslt looks now
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="dropDown" select="4"/>
        
        

    <!-- The fun starts here -->
    <ul id="menyn">
      

      <li>
           <xsl:attribute name="class">
             <xsl:if test="$currentPage/@level=$level">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
          <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>
         <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>
    And this how my menu looks now
    My Blog
    Blog
     - 2011
    Pages
     - About
     - Contact
     - Portfolio
    Thanks!
    Best regars Jonas
Please Sign in or register to post replies

Write your reply to:

Draft