Copied to clipboard

Flag this post as spam?

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


  • Nauman 98 posts 118 karma points
    Feb 24, 2010 @ 14:03
    Nauman
    0

    breadcrumb level in xslt

    Hi I am using a breadcrumb on mysite generated by xslt and it populates the breadcrumb properly. I want to restrict the breadcrumb to 3 or 4 level of top nodes. Like if I am on 5th level of page and breadcrumb shows all the 5 pages, i just want to display the top 3. how can i do that in following 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"/>

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

    <xsl:template match="/">

    <!-- start writing XSLT -->

     <xsl:if test="$currentPage/@level &gt; $minLevel">
        <div id="BreadCrumb">
          <ul>
            <xsl:for-each select="$currentPage/ancestor::node [@level &gt; $minLevel and string(data [@alias='umbracoNaviHide']) != '1']">
             
                <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="@nodeName"/>
                </a>
              &gt;
            </xsl:for-each>
            <!-- print currentpage -->
              <xsl:value-of select="$currentPage/@nodeName"/>
          </ul>
        </div>
        </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    ===========================================

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 24, 2010 @ 14:22
    Dirk De Grave
    0

    Add an extra parameter

    <xsl:variable name="maxLevel" select="3"/>

    and change your for-each to match the one below:

    <xsl:for-each select="$currentPage/ancestor::node [@level &gt; $minLevel and @level &lt;= $maxLevel and string(data [@alias='umbracoNaviHide']) != '1']">

    (btw, I think you need to have a li element in your for-each as well)

    Hope this helps.

    Regards,

    /Dirk

  • Nauman 98 posts 118 karma points
    Feb 24, 2010 @ 14:41
    Nauman
    0

    Dirk

    This was great healp, I was doing same thing with variable but my foreach check was not mature as yours. Thanks

    Cheers

    Nauman

Please Sign in or register to post replies

Write your reply to:

Draft