Skip to content

Instantly share code, notes, and snippets.

@xpathr
Created May 10, 2012 14:40
Show Gist options
  • Select an option

  • Save xpathr/2653491 to your computer and use it in GitHub Desktop.

Select an option

Save xpathr/2653491 to your computer and use it in GitHub Desktop.
Basic Breadcrumb by ashooner
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" indent="yes" method="xml" />
<!--
Basic Symphony Breadcrumb
Version .1
Author: Andrew Shooner
This is a basic breadcrumb utilizing just the default Symphony navigation datasource and $current-page-id parameter.
It does not handle url parameters -->
<!-- paste apply-templates element below where you want the breadcrumb
<xsl:apply-templates select="/data/navigation" mode='breadcrumb' />
-->
<xsl:template match="/data/navigation" mode="breadcrumb">
<ul class='breadcrumb'>
<li><a href="/">Home</a></li>
<xsl:apply-templates select="page[.//page[@id = $current-page-id]] | page[@id = $current-page-id]" mode="breadcrumb"/>
</ul>
</xsl:template>
<xsl:template match="page" mode="breadcrumb">
<xsl:param name="base-url" select="'/'"/>
<xsl:param name="this-page-url" select="concat($base-url, ./@handle, '/')" />
<xsl:choose>
<xsl:when test="@id = $current-page-id">
<li><xsl:value-of select="name"/></li>
</xsl:when>
<xsl:otherwise>
<li><a href="{$this-page-url}"><xsl:value-of select="name" /></a></li>
<xsl:apply-templates select="page[.//page[@id = $current-page-id]] | page[@id = $current-page-id]" mode='breadcrumb'>
<xsl:with-param name="base-url" select="$this-page-url" />
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment