Copied to clipboard

Flag this post as spam?

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


  • Zagros 12 posts 32 karma points
    Dec 17, 2010 @ 18:51
    Zagros
    0

    basic XSLT macro for top naviagtion based on tutorial video

    hi guys,

    I can't get the basic macro working.  Here is the xslt

    <?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 class="r">
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
    <li class="l">
    <a href="{umbraco.library:NiceUrl(@id)}" class="l off">
    <span class="l left"></span>
    <span class="l mid">
    <xsl:value-of select="@nodeName"/></span>
    <span class="l right"></span>
    <span class="clr nf"></span>
    </a>
    <div class="clr nf"></div>
    </li>
    </xsl:for-each>
    <li class="nf clr"></li>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    The macro above always renders this below (ie the for loop is never iterated)

    <ul class="r">
    <li class="nf clr"></li>
    </ul>

    Here is the site content structure.  Just a homepage so far.

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 17, 2010 @ 19:53
    Tom Fulton
    0

    Hi,

    It's because you don't have any content yet.  The for loop is going up to the Home node (level 1) and listing out child nodes, and since there are none it never hits the for loop.

    If you add some subpages under Home they should show up.

    I typically add the Home link manually right before the for-each loop, just linking it to "/"

    Thanks,
    Tom

  • Zagros 12 posts 32 karma points
    Dec 18, 2010 @ 00:54
    Zagros
    0

    thanks so much

Please Sign in or register to post replies

Write your reply to:

Draft