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?
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 " "> ]>
<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 > $minLevel">
<div id="BreadCrumb">
<ul>
<xsl:for-each select="$currentPage/ancestor::node [@level > $minLevel and string(data [@alias='umbracoNaviHide']) != '1']">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
>
</xsl:for-each>
<!-- print currentpage -->
<xsl:value-of select="$currentPage/@nodeName"/>
</ul>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
===========================================
Add an extra parameter
and change your for-each to match the one below:
(btw, I think you need to have a li element in your for-each as well)
Hope this helps.
Regards,
/Dirk
Dirk
This was great healp, I was doing same thing with variable but my foreach check was not mature as yours. Thanks
Cheers
Nauman
is working on a reply...