Copied to clipboard

Flag this post as spam?

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


  • doWhileSomething 11 posts 31 karma points
    Aug 08, 2011 @ 21:43
    doWhileSomething
    0

    Menu Navigation (drop down menus)

    i

  • doWhileSomething 11 posts 31 karma points
    Aug 08, 2011 @ 21:49
    doWhileSomething
    0

    I applogize in advance if this has been covered, but am looking for a little help getting sub navigation work outside of the current page.

    Basically, I want to generate a menu for category with only next level children (no recursion).

    I'm using this macro/xslt:

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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

      <xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
      
    <!-- The fun starts here -->
        
    <xsl:if test="count($items) &gt; 0">
    <ul>
    <xsl:for-each select="$items">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
        </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    But only generates the child objects for the given parent node while on the parent node (page).  I want to generate all sub menus for all parent nodes (sections) to build a hover menu.  If this doesn't make sense, I will try to elaborate further.

     

    I'm using the 4.7 build

    Thanks in advance.

  • Amir Khan 1284 posts 2741 karma points
    Aug 08, 2011 @ 22:19
    Amir Khan
    0

    Have you taken a look at the sitemap XSLT Template? Unless I'm misunderstanding, it'll probably do what you need.

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 08, 2011 @ 22:40
    Bo Damgaard Mortensen
    0

    Hi,

    Have you had a peek at the Cogworks Flexible Navigation package? I just made a dropdown menu with that and some CSS - didn't take longer than about 15 mins to do :-) 

    What I did was:

    1. Install Cogworks Flexible Navigation
    2. Go to line 146 in the XSLT file and replace thestatement with this:
    3. <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc]/child::*[@isDoc]">1xsl:when>
    4. Style the submenu with these classes: lv2 and .lv2 li
    Hope this helps :-)
    / Bo
  • doWhileSomething 11 posts 31 karma points
    Aug 09, 2011 @ 02:05
    doWhileSomething
    0

    Thanks, this installs fine, but still only renders one menu tab's sub items.  What I would like to do, is render all sub menus (at the same time) for all parent categories.

    So, when hovering over a given tab, menu items will drop down.  I'm fine with the CSS/JS, it's getting the entire menu to generate that I'm having trouble with.  Once I can get it onto the document, the rest I can take care of.  Is there documentation around this? 

  • doWhileSomething 11 posts 31 karma points
    Aug 09, 2011 @ 02:14
    doWhileSomething
    0

    Amir, I don't see the xslt sitemap file; is this something I need to install separately?

    I realy appreciate the help, thanks everyone.

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 09, 2011 @ 07:15
    Fuji Kusaka
    0

    Hi,

    Here  is something you can try in your XSLT. Try changing this

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

    <xsl:paramname="currentPage"/>

    <xsl:templatematch="/">

      <xsl:variablename="items"select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
     
    <!-- The fun starts here -->
       
    <xsl:iftest="count($items) &gt; 0">
    <ul>
    <xsl:for-eachselect="$items">
      <li>
        <ahref="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-ofselect="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
        </xsl:if>

    </xsl:template>
    </
    xsl:stylesheet>

     

    to

    <xsl:variable name="level" select="1"/>     <!-- Depending on how you have your website Content Section Structured Generally your default is on Level 1 --> 

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>  
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
       <li>        
        <ahref="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-ofselect="@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>
                 <ahref="{umbraco.library:NiceUrl(@id)}">
                   <xsl:value-ofselect="@nodeName"/>
                  </a> 
              </li>
            </xsl:for-each>
          </ul>
        </xsl:if>
        <!-- End Of Drop Down Menu -->
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    If you are ok with CSS just used yours to get it to display on hover


    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 09, 2011 @ 07:16
    Fuji Kusaka
    0

    Weird, my post was duplicated on Submit!!! Sorry for that

  • doWhileSomething 11 posts 31 karma points
    Aug 09, 2011 @ 15:47
    doWhileSomething
    0

    Thanks, this worked great. There was a little issue with the formatted text, no space between "value-ofselect" should be "value-of select".  Thanks a bunch.

    For anyone else, here is the entire xslt file:

    <?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"
      exclude-result-prefixes="msxml umbraco.library">
        

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:variable name="level" select="1"/>     <!-- Depending on how you have your website Content Section Structured Generally your default is on Level 1 -->
    <xsl:param name="currentPage"/>
    <xsl:template match="/">

    <!-- The fun starts here -->
    <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>
        <!-- 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>
                 <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
  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 09, 2011 @ 15:52
    Fuji Kusaka
    0

    Hi

    I just noticed the formatting i dont know why the spaces were removed but great if you got it working. Remember to mark this thread as solved for others.

     

    //fuji

  • doWhileSomething 11 posts 31 karma points
    Aug 09, 2011 @ 17:01
    doWhileSomething
    0

    I don't see an option do mark the thread as solved?  I'll try adding it to the description if that is still possible.

Please Sign in or register to post replies

Write your reply to:

Draft