Copied to clipboard

Flag this post as spam?

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


  • smercer 39 posts 67 karma points
    Jun 30, 2010 @ 15:52
    smercer
    0

    creating a multi-level nav

    I'd like to create a nav that displays multiple levels. Like the expanding nav example, but with all children showing for each node at level 1.

    Item

    - child

    - child

    -child

    Item 2

    - child

    - child

    - child

     

    I can only seem to get the nav to reder the children of the current node. Any thoughts?

     

     

  • Chris Dunn 210 posts 401 karma points
    Jun 30, 2010 @ 16:11
    Chris Dunn
    0

    smercer,

    If you are using $currentPage as you starting point and traversing downward, you will only get child nodes or descendants of the current page.  Try using the umbraco.library function GetXMLAll() to get the entire cache as your starting point.  I use this when creating accordian menus for a site.

    Something like this:

    <xsl:for-each select="umbraco.library:GetXmlAll()/descendant ">
    </xsl:for-each>

    -Chris 

  • Sander Houttekier 114 posts 163 karma points
    Jun 30, 2010 @ 16:44
    Sander Houttekier
    0

    do you have runway installed on your site?

    if not i'll post an xslt snippit here,

    runway has a nice amount of runway modules, 1 of that is a menu exactly as you propose it, Level1 nav with jquery animated lvl2 nav.

    the script is however in the legacy xml schema, but you can get the logic of it.
    should not be to hard to rewrite to 4.5's new xml schema if you are using the 4.5 that is...

    it uses some javascript / jquery to animate the menu... if you need them, you can probably grab them somewhere on the internet, or download the runway module "runwayDropdownNavigation"
    thats the one.

     

     

    <xsl:param name="currentPage"/>
    <!-- update this variable on how deep your navigation should be -->
    <xsl:variable name="maxLevel" select="5"/>
    
    <xsl:template match="/">
        <xsl:value-of select="umbraco.library:AddJquery()"/>
        <xsl:value-of select="umbraco.library:RegisterJavaScriptFile('droppyJs', '/scripts/droppy.js')"/>
        <xsl:value-of select="umbraco.library:RegisterStyleSheetFile('droppyCss', '/css/dropdownnavigation.css')"/>
        <xsl:variable name="droppyJS">$(function() {$('#dropdownNavigation').droppy();});</xsl:variable>
        <xsl:value-of select="umbraco.library:RegisterClientScriptBlock('droppyJs', $droppyJS, true())"/>
    
        <ul id="dropdownNavigation">
            <xsl:call-template name="drawNodes">  
            <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>  
            </xsl:call-template>
        </ul>
    </xsl:template>
    
    <xsl:template name="drawNodes">
    <xsl:param name="parent"/> 
        <xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
            <xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevel]"> 
                <li>  
                    <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName"/></a>  
                    <xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevel]) &gt; 0">   
                        <ul>
                            <xsl:call-template name="drawNodes">    
                            <xsl:with-param name="parent" select="."/>    
                            </xsl:call-template>  
                        </ul>
                    </xsl:if> 
                </li>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
  • Tim 225 posts 690 karma points
    Jul 01, 2010 @ 13:59
    Tim
    0

    Hi

    Currently this feature is not supported - you'd need to mod the XSLT slightly or roll your own nav I'm afraid. You can tell it to expand all children but I don't think that will help in this case.

    I can certainly look at this as an option for a future release. Basically I could add a param to expand all nodes down to a certain level which would do what you are looking for, 

    Tim

     

     

  • Billy Koch 8 posts 28 karma points
    Jul 19, 2010 @ 22:58
    Billy Koch
    0

    So there is no way to make a drop down with this navigation?  

  • Greg Berlin 818 posts 634 karma points
    Feb 19, 2011 @ 10:42
    Greg Berlin
    0

    It's an easy fix Billy... in the 4.5 version, line 146 of the XSLT, change:

    <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc]">1</xsl:when>
    

    to:

    <xsl:when test="$currentPage/ancestor-or-self::*[@isDoc]/child::*[@isDoc]">1</xsl:when>

     

    If you want to make this configurable (which i did), you can add a parameter to the macro:

    <xsl:variable name="showAllChildren" select="/macro/showAllChildren"></xsl:variable>
    
    and then test against that parameter:
            <!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
            <xsl:variable name="isBranch">
              <xsl:choose>
                <xsl:when test="$showAllChildren = 1">
                  <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/child::*[@isDoc]">1</xsl:if>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc][@id = $currentNodeID]/child::*[@isDoc]">1</xsl:if>
                </xsl:otherwise>
              </xsl:choose>          
            </xsl:variable>
    
    Tim, can you include that in the next version?
  • Tim 225 posts 690 karma points
    Feb 24, 2011 @ 11:55
    Tim
    0

    Hi,

    Sounds like a good inclusion. I'm considering some major restructuring of this package to make it easier to customise.

    Kindest Regards

    Tim

  • Mike 81 posts 101 karma points
    Nov 26, 2011 @ 02:25
    Mike
    0

    I have a question, how would a client add this child to the xslt. I do not show the tool as having that option only sort order.

    How would my client login and add these in themselves via the "document types" > "tabs" tab.

    Thanks for any assistance!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 26, 2011 @ 08:59
    Jan Skovgaard
    0

    Hi Mike

    Not quite sure what you're asking about here? :)

    Your clients should not have access to modify the XSLT at all. Only developers should be able to touch the XSLT files.

    But on your document types you can add some properties, which you can use as parameters in the XSLT file or you can simply add some macro parameters in the developer section and then allow the macro to be inserted in the rich text editor where the client can then set the parameters for the macro when they insert it.

    Is this anyway near what you're having in mind? :)

    /Jan

  • Mike 81 posts 101 karma points
    Nov 26, 2011 @ 17:06
    Mike
    0

    Hi Jan,

    Thanks for responding so quickly. I will try and and explain further. Hopefully it will make more sense :).

    I got it figured out... duh. Watched a video and it all makes sense now. But I could use help with the XLST to get the main nav to have a dropdown :D

    Thanks again!

    OH Here is the XSLT of the UMBTopNavigation.XSLT File. If someone who is well versed in this could help me with the above fix to make the top nav have dropdowns, I would be most grateful. Looking through all the videos and tinkering around with it but any time saving help would be awesome!!!


       
    ]>
      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">


       

       

       
       

       

         
     

     

              

      •         
                     home current
                
                 Home
              

     

             

     

     

         

     

         

     

       

     

  • siriosus 3 posts 23 karma points
    Jun 21, 2012 @ 20:33
    siriosus
    0

    Thanks Greg! It is exactly what I needed. Tim I think this update must be in the next release of package

    Regards

Please Sign in or register to post replies

Write your reply to:

Draft