Skip to content

Instantly share code, notes, and snippets.

@stentebjerg
Last active August 29, 2015 14:06
Show Gist options
  • Save stentebjerg/961bd20383e51ef45df8 to your computer and use it in GitHub Desktop.
Save stentebjerg/961bd20383e51ef45df8 to your computer and use it in GitHub Desktop.
Breadcrumb.xslt
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="utf-8" />
<xsl:param name="html-content-type" />
<!-- Get primary domain -->
<xsl:variable name="primarydomain" select="/NavigationTree/Settings/GlobalTags/Global.Area.Primarydomain" />
<!-- Loading translations.xml -->
<xsl:variable name="translationfile" select="document(concat('http://',$primarydomain, '/Files/Templates/Translations.xml'))/translations" />
<!-- Get current language -->
<xsl:variable name="current-language" select="/NavigationTree/Settings/GlobalTags/Global.Area.LongLang" />
<xsl:template match="/NavigationTree">
<xsl:if test="//ancestor-or-self::Page[@ShowInLegend ='True'] and /NavigationTree/Settings/Pageview/@AreaFirstPageID != /NavigationTree/Settings/Pageview/@ID and count(//Page) &gt; 0">
<div class="e-breadcrumb">
<div class="container">
<ul class="breadcrumb hidden-phone">
<li>
<xsl:call-template name="translate">
<xsl:with-param name="translationkey" select="'GlobalText_Breadcrumb_PrefixText'" />
<xsl:with-param name="defaulttranslation" select="'Du er her:'" />
<xsl:with-param name="translationMode" select="'global'" />
</xsl:call-template>
</li>
<li>
<a href="/">
<xsl:call-template name="translate">
<xsl:with-param name="translationkey" select="'GlobalText_Breadcrumb_FrontpageLinkText'" />
<xsl:with-param name="defaulttranslation" select="'Forside'" />
<xsl:with-param name="translationMode" select="'global'" />
</xsl:call-template>
</a>
</li>
<xsl:apply-templates select="Page">
<xsl:with-param name="depth" select="1" />
</xsl:apply-templates>
</ul>
<ul class="breadcrumb visible-phone">
<li>
<xsl:call-template name="translate">
<xsl:with-param name="translationkey" select="'GlobalText_Breadcrumb_PrefixText'" />
<xsl:with-param name="defaulttranslation" select="'Du er her:'" />
<xsl:with-param name="translationMode" select="'global'" />
</xsl:call-template>
</li>
<li>
<xsl:value-of select="Page/@MenuText" />
</li>
</ul>
</div>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="//Page">
<xsl:param name="depth" />
<xsl:if test="@ShowInLegend !='False'">
<li>
<xsl:attribute name="itemscope"></xsl:attribute>
<xsl:attribute name="itemtype">http://data-vocabulary.org/Breadcrumb</xsl:attribute>
<span class="divider">/</span>
<a>
<xsl:attribute name="href">
<xsl:value-of select="@FriendlyHref" /></xsl:attribute>
<xsl:attribute name="itemprop">url</xsl:attribute>
<span>
<xsl:attribute name="itemprop">title</xsl:attribute>
<xsl:value-of select="@MenuText" />
</span>
</a>
</li>
</xsl:if>
<xsl:if test="count(Page)">
<xsl:apply-templates select="Page">
<xsl:with-param name="depth" select="$depth+1" />
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<!-- Translation template -->
<xsl:template name="translate">
<xsl:param name="translationkey"/>
<xsl:param name="defaulttranslation"/>
<xsl:choose>
<xsl:when test="$translationfile/key[@name=$translationkey]">
<xsl:value-of select="$translationfile/key[@name=$translationkey]/translation[@culture=$current-language]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$defaulttranslation"/>
</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