Skip to content

Instantly share code, notes, and snippets.

@uniquelau
Created September 29, 2011 10:28
Show Gist options
  • Save uniquelau/1250479 to your computer and use it in GitHub Desktop.
Save uniquelau/1250479 to your computer and use it in GitHub Desktop.
navFiltered
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xsl:stylesheet [
<!-- For easier customization -->
<!ENTITY NotDoc "not(self::layoutGridFolders)">
<!-- Compatibility stuff -->
<!ENTITY NiceUrl "umb:NiceUrl">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:umb="urn:umbraco.library"
exclude-result-prefixes="umb"
>
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="filter" select="/macro/filter" />
<!-- Children 'Fixed' Navigation - Laurie 14th July -->
<!-- Modified 6th September 2011, for Abbott.Corporate -->
<xsl:template match="/">
<!-- Home Node -->
<li>
<xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::publicHome [@isDoc]/@id">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<a href="/">Home</a>
</li>
<!-- Let's go! -->
<xsl:apply-templates select="$currentPage/ancestor-or-self::* [@level = 1]/* [@isDoc and not(contains(metaSitemap, 'Page'))] [&NotDoc;] [contains(layoutNavigation, $filter)]"/>
</xsl:template>
<xsl:template match="* [@isDoc and not(contains(metaSitemap, 'Page'))] [&NotDoc;]">
<xsl:call-template name="list-item">
<xsl:with-param name="parent" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="list-item">
<xsl:param name="parent" />
<li>
<xsl:if test="position() = '1'">
<xsl:attribute name="class">first</xsl:attribute>
</xsl:if>
<xsl:if test="@id = $currentPage/@id">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<a href="{&NiceUrl;(@id)}">
<xsl:if test="url !=''">
<xsl:call-template name="processLink">
<xsl:with-param name="link" select="url" />
</xsl:call-template>
</xsl:if>
<xsl:if test="@id = $currentPage/@id">
<xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName" />
</a>
<!-- If the current page is active then show its children -->
<!-- we use ancestor-or-self here, so the menu stays open when we traverse the tree -->
<xsl:if test="* [@isDoc] [&NotDoc;] and @id = $currentPage/ancestor-or-self::*/@id and not(contains($parent/metaSitemap, 'Children'))">
<ul>
<xsl:for-each select="* [@isDoc and not(contains($parent/metaSitemap, 'Children'))] [&NotDoc;]">
<xsl:call-template name="list-item">
<xsl:with-param name="parent" select="." />
</xsl:call-template>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:template>
<!-- This macro provides navigation, that always remains at the set level (see apply-templates) -->
<!-- However when a page is active at Level4, it will list the other child pages -->
<!-- Includes -->
<xsl:include href="_wysiwyg.xslt" />
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment