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.
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 <= $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 <= $maxLevel]) > 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>
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,
<!--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>
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? :)
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!!!
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?
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:
-Chris
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.
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
So there is no way to make a drop down with this navigation?
It's an easy fix Billy... in the 4.5 version, line 146 of the XSLT, change:
to:
If you want to make this configurable (which i did), you can add a parameter to the macro:
Hi,
Sounds like a good inclusion. I'm considering some major restructuring of this package to make it easier to customise.
Kindest Regards
Tim
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!
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
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
current
Thanks Greg! It is exactly what I needed. Tim I think this update must be in the next release of package
Regards
is working on a reply...