Copied to clipboard

Flag this post as spam?

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


  • Hundebol 167 posts 314 karma points
    Jul 02, 2009 @ 09:23
    Hundebol
    0

    Submenu with 3 levels

    Hi,

    I am building a site with 4 levels in navigation. I have a top menu for the first level, and the rest should be in a submenu.

    I got an XLST file from another post: http://forum.umbraco.org/yaf_postst3421_Creating-a-3rd-and-dare-I-say-4th-level-navigation.aspx

    And i works almost as it should - the only thing wrong, is that is moves the 2nd level down to 3rd level, when you are on a 3rd level link!

    My navigation is like this:

    Home
    - About
    - - organisation
    - - - Chart
    - - - People
    - - History
    - - - 1987

    if i go to the People site, the History site "moves down" in the list so that it looks like a 3rd level link.

    It is maybe easier to explain in pictures: http://www.pado.dk/menustructure.jpg

     

    My XLST file looks like this:

    <?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"/>

    <xsl:param name="startLevel" select="2"/>

    <xsl:template match="/">
    <xsl:if test="count($currentPage/ancestor-or-self::node [@level = $startLevel]/node) &gt; 0">
    <ul id="nav">
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = $startLevel]/node">
    <xsl:call-template name="drawnode">
    <xsl:with-param name="level" select="1"/>
    </xsl:call-template>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </xsl:template>

    <xsl:template name="drawnode">
    <xsl:param name="level"/>
    <li>
    <xsl:choose>
    <xsl:when test="@id=$currentPage/@id">
    <xsl:attribute name="class">level<xsl:value-of select="$level"/>selected</xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
    <xsl:attribute name="class">level<xsl:value-of select="$level"/></xsl:attribute>
    </xsl:otherwise>
    </xsl:choose>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>


    <xsl:if test="count(descendant-or-self::node [@id=$currentPage/@id]) &gt; 0">
    <ul id="nav">
    <xsl:for-each select="node">
    <xsl:call-template name="drawnode">
    <xsl:with-param name="level" select="number($level)+1"/>
    </xsl:call-template>
    </xsl:for-each>
    </ul>
    </xsl:if>
    </li>
    </xsl:template>

    </xsl:stylesheet>

     

    Hope to get some help, as i think it is probably just a little error somewhere.

    Best Regards,
    Brian

  • Hundebol 167 posts 314 karma points
    Jul 02, 2009 @ 10:58
    Hundebol
    0

    If it is easier, then the original code, by hoehler, looks like this:

     

    <?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"/>
    <xsl:param name="startLevel" select="2"/>

    <xsl:template match="/">
        <xsl:if test="count($currentPage/ancestor-or-self::node [@level = $startLevel]/node) &gt; 0">
            <div id="nav">
                <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = $startLevel]/node">
                    <xsl:call-template name="drawnode">
                        <xsl:with-param name="level" select="1"/>
                    </xsl:call-template>
                </xsl:for-each>
            </div>
        </xsl:if>
    </xsl:template>

    <xsl:template name="drawnode">
        <xsl:param name="level"/>
        <div>
            <xsl:choose>
                <xsl:when test="@id=$currentPage/@id">
                    <xsl:attribute name="class">level<xsl:value-of select="$level"/>selected</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="class">level<xsl:value-of select="$level"/></xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
           
        </div>
        <xsl:if test="count(descendant-or-self::node [@id=$currentPage/@id]) &gt; 0">
            <xsl:for-each select="node">
                <xsl:call-template name="drawnode">
                    <xsl:with-param name="level" select="number($level)+1"/>
                </xsl:call-template>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

  • kmacdonell 28 posts 45 karma points
    Jul 02, 2009 @ 12:02
    kmacdonell
    0

    Hi,

    Can  you please post the markup that is generated when the problem ocurrs?

    I have something that does this sort of thing but it's so specific to the site it was used on that it would take me a long time to strip it back to basics. I'm pretty sure I'll be able to fix this though.

    Thanks,
    Kevin

  • Hundebol 167 posts 314 karma points
    Jul 02, 2009 @ 12:58
    Hundebol
    0

    When the problem occurs, the html markup looks like this: class</span>=<span class="attribute-value">"level1"</span>><<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"/about-bw/organisation.aspx"</span>>Organisation</<span class="end-tag">a</span>><<span class="start-tag">ul</span><span class="attribute-name"> id</span>=<span class="attribute-value">"nav"</span>><<span class="start-tag">li</span><span class="attribute-name"> class</span>=<span class="attribute-value">"level2selected"</span>><<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"/about-bw/organisation/organisation-chart.aspx"</span>>Organisation Chart</<span class="end-tag">a</span>><<span class="start-tag">ul</span><span class="attribute-name"> id</span>=<span class="attribute-value">"nav" </span><span class="error"><span class="attribute-name">/</span></span>></<span class="end-tag">li</span>></<span class="end-tag">ul</span>></<span class="end-tag">li</span>><<span class="start-tag">li</span><span class="attribute-name"> class</span>=<span class="attribute-value">"level1"</span>><<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"/about-bw/history.aspx"</span>>History</<span class="end-tag">a</span>></<span class="end-tag">li</span>></<span class="end-tag">ul</span>>

    I hope this is what you mean?

     

  • Hundebol 167 posts 314 karma points
    Jul 02, 2009 @ 12:59
    Hundebol
    0

    There was a problem with the code, sorry! Here it is again:

    When the problem occurs, the html markup looks like this:

    <ul id="nav"><li class="level1"><a href="/about-bw/organisation.aspx">Organisation<ul id="nav"><li class="level2selected"><a href="/about-bw/organisation/organisation-chart.aspx">Organisation Chart<ul id="nav" /></li></ul></li><li class="level1"><a href="/about-bw/history.aspx">History</li></ul>

    I hope this is what you mean?

  • Hundebol 167 posts 314 karma points
    Jul 02, 2009 @ 12:59
    Hundebol
    0

    There was a problem with the code, sorry! Here it is again:

    When the problem occurs, the html markup looks like this:

    <ul id="nav"><li class="level1"><a href="/about-bw/organisation.aspx">Organisation<ul id="nav"><li class="level2selected"><a href="/about-bw/organisation/organisation-chart.aspx">Organisation Chart<ul id="nav" /></li></ul></li><li class="level1"><a href="/about-bw/history.aspx">History</li></ul>

    I hope this is what you mean?

  • Hundebol 167 posts 314 karma points
    Aug 21, 2009 @ 10:45
    Hundebol
    0

    Suddenly a solution popped up, the Cogworks Flexible Navigation! Great Package!

    The link: http://our.umbraco.org/projects/cogworks---flexible-navigation

    Thank you Tim Saunders! Your package was the solution, so how do i set a solution to this thread?

    best regards,
    Brian

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies