Copied to clipboard

Flag this post as spam?

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


  • Bjørn-Tore 4 posts 24 karma points
    Apr 11, 2011 @ 14:41
    Bjørn-Tore
    0

    Newbie - navigation issue

    Hi -

    Playing with my first Umbraco install. I have a navigation structure like:

    -Startpage
    --About
    --Services
    --Contact

    And so on.

    Using the Xslt "navigation by level" template I cant get the Startpage to show up in navigation menu.
    The other menu items show just fine.

    Any idea on how I can also show "Startpage" ?

    Code from template;

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

    <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:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

     

    Kind r

    Bjørn.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 11, 2011 @ 14:49
    Tom Fulton
    1

    Ho Bjørn,

    The reason it's not showing the startpage is the XPath in the for-each loop is selecting the Startpage (ancestor-or-self::* [@level=1]), then selecting all nodes beneath it (/* ...)

    I think most people typically add in their "start page" link manually, before the for-each loop, since the URL is usually just "/".  Example:

    <ul>
    <li><a href="/">Startpage</a></li>
    <xsl:for-each .... >
    ...
    </xsl:for-each>
    </ul>

    Hope this helps,
    Tom

  • Bjørn-Tore 4 posts 24 karma points
    Apr 12, 2011 @ 09:00
    Bjørn-Tore
    0

    Hi -

    That worked. So easy. Thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft