Copied to clipboard

Flag this post as spam?

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


  • TomLeads 20 posts 42 karma points
    Mar 16, 2011 @ 17:29
    TomLeads
    0

    Third/fourth level nav

    Hello. I'm using one of the default sub-nav XLST provided by Umbraco to list my sub nav. But it only goes down a couple of levels.

    Here is my setup

    Home
       > About us
            > Profiles
                > Profile 1
                > Profile 2
            > Something Else

    At the moment if I go to About us or Profiles, the sub-menu is correct. However it does not display the Profile 1 navigation.

    Does that make sense?

    Here is my current code:

    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

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

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="2"/>

    <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:if test="$currentPage/ancestor-or-self::*/@id = current()/@id">
    <!-- we're under the item - you can do your own styling here -->
    <xsl:attribute name="class">selected</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    I tried using this but it doesn't display anything.

    http://our.umbraco.org/forum/templating/templates-and-document-types/6730-Third-level-in-menu-disappears

    Thanks for any help!

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 16, 2011 @ 18:58
    Jan Skovgaard
    0

    Hi Tom

    I guess it's because the level attribute has been set to '2'? Try changing this value to either 3 or 4. Does it work then?

    /Jan

  • TomLeads 20 posts 42 karma points
    Mar 17, 2011 @ 11:13
    TomLeads
    0

    If I change it to 3 then the menu only displays when on the "Profile 1" page.

    So guessing I need a more complicated XLST?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2011 @ 22:45
    Jan Skovgaard
    0

    Hi Tom

    Woops...I appoligize for not being fully awake when writing my first post - that of course defines what level the navigation should be starting from not the depth. Do'h!

    Maybe you should have a look at the predefined sitemap xslt that appears in the dropdown when creating a new XSLT file? - In here you can define the depth that the sitemap should go to...

    Basically it writes out ul's nested in each other. It should be a matter of changing the $currentPage parameter to modify it to your needs I guess.

    But perhaps someone else in here has a better solution (I know there are better ways to do this and will post later if no one does before me, just need to get to another machine first).

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft