May
30
2010

Umbraco: Breadcrumb Trail



Comments available as RSS 2.0

I’ve been using Umbraco recently, and always find it hard to find XSL templates or spend hours tweaking one when countless other people must have done the same thing, but not published the finished stylesheet.

Below is a navigation breadcrumb template which prints a trail to the current page, starting with level 1.

<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE xsl:Stylesheet [
	<!ENTITY amp "&#38;">
    <!ENTITY nbsp "&#x00A0;">
    <!ENTITY raquo "&#187;">
]>
 
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library"
	exclude-result-prefixes="msxml umbraco.library">
	<xsl:output method="xml" omit-xml-declaration="yes" />
	<xsl:param name="currentPage" />
 
	<xsl:template match="/">
        <span class="breadcrumb">
            <xsl:for-each select="$currentPage/ancestor::node [string(data [@alias='umbracoNaviHide']) != '1']">
                <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:attribute name="title">
                        <xsl:value-of select="@nodeName" />
                    </xsl:attribute>
                    <xsl:value-of select="@nodeName" />
                </a>
                <xsl:if test="@level != 0">
                    &raquo;
                </xsl:if>
            </xsl:for-each>
            <xsl:value-of select="$currentPage/@nodeName" />
        </span>
    </xsl:template>
</xsl:stylesheet>

Comments

Leave a Comment

Login using OpenID or enter your details below to leave a comment.

OpenID
Anonymous


Comment