Copied to clipboard

Flag this post as spam?

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


  • sauritas 37 posts 57 karma points
    Aug 16, 2010 @ 13:57
    sauritas
    0

    TopMenu Problems

    Hello,

    I'm newbie in Umbraco and I'm trying to develop a site. This site should have three menus: letf, top and rigth; each one with refering to different nodes. I did ok left and right one (using mtt_ultimateNav).

    What I'm trying to do now is a DropDown Navigation Menu. I am using for that RunawayDropDownNavigation. At first I have the problem that I only want TopMenu node... at last I done it! But now I have another problem: when I click in ANY menu tag (left, rigth or top), an error occurs (Error parsing XSLT file: \xslt\RunwayDropdownNavigation.xslt)

     

    This is my addapted code to RunwayDropdownNavigation.xslt... could anyone help me?

     

    <?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: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/descendant-or-self::node[@nodeName = 'MenuTop']"/>


    </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>
    </xsl:stylesheet>

     

    Thanks a lot!

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 14:32
    Sascha Wolter
    0

    Hi sauritas,

    as this is your top-navigation it will appear on every one of your web pages and look exactly the same (as opposed the other menues which are navigating sub trees)? Change the xsl:with-param line to

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node[@nodeTypeAlias={your-homepage-alias}]/descendant-or-self::node[@nodeName = 'MenuTop']"/>

    and change {your-homepage-alias} to the alias of your homepage doc type. Alternatively you can just do this if the ID of your MenuTop node is fixed and e.g. 1234:

    <xsl:with-param name="parent" select="umbraoc.library:GetXmlNodeById(1234)" />

    I would also move the whole AddJQuery part to registering the droppyJS script out of the xslt, presumably it is also contained in the other menu scripts and you really want this to happen only once on your site.

    If I understand it correctly then you have a tree something similar to this:

    homepage
    - top navigation
    -- pages that appear in the top nav
    - left navigation
    - right navigation

    Depending on the structure of your web site it might not be the worst idea, yet in general you shouldn't structure your content nodes by menus, one of the reasons is that your links will look like this: /top-navigation/about-us. There are ways around this of course but it's cumbersome and what happens if you have to move content around?

    The two alternatives I have implemented so far are:

    - have a property on all of your web pages of type true/false which reads 'display link in top navigation?'; to create the top navigation I simply create an xsl:for-each loop which lists all documents that have this property set

    - have something like a tree multi picker on the homepage where the users can build up their top menu by actively selecting the nodes that should appear in there. To create the menu I just take the IDs of the nodes saved in the property and get the nodes while looping through the IDs.

    Hope that helps,
    Sascha

  • sauritas 37 posts 57 karma points
    Aug 16, 2010 @ 15:25
    sauritas
    0

    Thanks very much!!!! It runs!!!!! I tried the first thing you told me.

     

    At this moment, I am learning Umbraco and I am happy only with have a Menu preview. In the future, I will have to work with another person to develope a complete web site, so I will take your advices later (maybe in a pair of days).

     

    Thanks for the solution!!!!

     

    Pablo

  • Sascha Wolter 615 posts 1101 karma points
    Aug 16, 2010 @ 16:02
    Sascha Wolter
    0

    Excellent, glad you got it working! :)

  • sauritas 37 posts 57 karma points
    Aug 25, 2010 @ 17:47
    sauritas
    0

    Hi!

     

    Just for info. I have done what you told me about menus. I have created a new DataType called "MenuType" and the Render Control is a Chebox List with three items (Nvarchar): Top, Left, Right.

    So I have created a property in my doctypes called MenuType and all I have to do in my xslt archives ( have one for each menu) y filter (like done with umbracoNaviHide. It was easy and you where right and now my links look better.

     

    So thanks for the help!!!

Please Sign in or register to post replies

Write your reply to:

Draft