Copied to clipboard

Flag this post as spam?

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


  • Brian Juul Andersen 43 posts 97 karma points c-trib
    Oct 19, 2010 @ 14:24
    Brian Juul Andersen
    0

    Navigation Prototype - can´t get it working.

    Pretty new to umbraco and XSLT so go easy on me ;)

     

    I´ve tried to use the Navigation Prototype XSLT script to try to create a single level menu.

    After inserting the macro into the template the only thing the XSLT script returns is an empty set of <ul> </ul>-tags.

    No <li>´s  - but why ?

    I´ve tried to change the value of the level variable but had no succes with it.

    <xsl:variable name="level" select="0"/>

     

    The content tree is pretty simple...

    [content]

    -[page1]

    -[page2]

    I´ve checked that umbracoNaviHide is not set for the pages and that it is defined as a boolean (True/False) in the document type.

    Umbraco is version 4.5.2 with the new schema (snippet from umbracoSettings.config)

        <!-- to enable new content schema, this needs to be false -->
        <UseLegacyXmlSchema>false</UseLegacyXmlSchema>

     

    Here is what I´ve been working with - it´s close to the standard Navigation Prototype..


    <?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 -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul style="outline: 1px solid red; width: 10px; height: 10px;">
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @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>


    Any ideas to how I can get the script working and returning <li>´s as well ?

  • Rich Green 2245 posts 3893 karma points
    Oct 19, 2010 @ 14:30
    Rich Green
    0

    Hey Brian,

    It depends what level your content is on, it certainly wont be on 0 so try changing it to 2

    <xsl:variable name="level" select="2"/>

    If that doesn't work then post an image of your content tree and we can figure it out.

    Best of luck

    Rich

  • Brian Juul Andersen 43 posts 97 karma points c-trib
    Oct 19, 2010 @ 14:44
    Brian Juul Andersen
    0

    Here is the content tree.

     

    I´ve tried the levels 0, 1, 2, 3, 4 .. but still no luck.

  • Rich Green 2245 posts 3893 karma points
    Oct 19, 2010 @ 14:53
    Rich Green
    0

    Hi Brian,

    Not meaning to create you another problem, however unless 'Sprojtestobe' and ' NEK' are separate websites you should probably move them under a 'Home' Node, so your structure will look like this

    Content

    - Home

    - Sprojtestobe

    - NEK

    - Any other new content

    If you do this then and change the level to 2, you should get your li's listed.

    Rich

  • Brian Juul Andersen 43 posts 97 karma points c-trib
    Oct 19, 2010 @ 15:10
    Brian Juul Andersen
    0

    Ahaaaaa !

     

    I made the changes in the content tree and tried a few numbers for the level variable. Setting it to 1 gave me the <li>´s ! Yeeeeppiieeeh !! ;)

     

    Thanks for the quick reply Rich !

  • Brian Juul Andersen 43 posts 97 karma points c-trib
    Oct 19, 2010 @ 15:10
    Brian Juul Andersen
    0

    Ahaaaaa !

     

    I made the changes you suggested in the content tree and tried a few numbers for the level variable. Setting it to 1 gave me the <li>´s ! Yeeeeppiieeeh !! ;)

     

    Thanks for the quick reply Rich !

Please Sign in or register to post replies

Write your reply to:

Draft