<?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:ps="urn:percipientstudios-com:xslt"
exclude-result-prefixes="msxml umbraco.library ps">
<xsl:output method="xml" omit-xml-declaration="yes" />
<!--
======================================================================
NavigationHierarchy.xslt
======================================================================
Copyright 2008 Percipient Studios. All rights reserved.
www.percipientstudios.com======================================================================
-->
<!-- ============================================================ -->
<xsl:param name="currentPage"/>
<xsl:variable name="startingLevel">
<!-- what level in the content tree is the "top" of the navigation list generated? -->
<xsl:choose>
<xsl:when test="string(/macro/startingLevel) != ''">
<xsl:value-of select="/macro/startingLevel"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="stoppingLevel">
<!-- what level in the content tree is the lowest you want to display? -->
<xsl:choose>
<xsl:when test="string(/macro/stoppingLevel) != ''">
<xsl:value-of select="/macro/stoppingLevel"/>
</xsl:when>
<xsl:otherwise>3</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="showHome">
<!-- show a "Home" link for the top-level node? -->
<xsl:choose>
<xsl:when test="string(/macro/showHome) != ''">
<xsl:value-of select="/macro/showHome"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- ============================================================ -->
<xsl:template match="/">
<xsl:if test="$showHome = 1">
<ul class="Home">
<li>
<xsl:if test="$currentPage/ancestor-or-self::node [@level=$startingLevel]/@id = $currentPage/@id">
<xsl:attribute name="class">Current</xsl:attribute>
</xsl:if>
<a href="/">Home</a>
</li>
</ul>
</xsl:if>
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node/descendant-or-self::node [@level=$startingLevel]" />
</xsl:call-template>
</xsl:template>
<!-- ============================================================ -->
<xsl:template name="drawNodes">
<xsl:param name="parent" />
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0
or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1
and umbraco.library:HasAccess($parent/@id, $parent/@path) = 1)">
<ul>
<xsl:attribute name="class">
<xsl:text>Level</xsl:text><xsl:value-of select="$parent/node/@level"/>
</xsl:attribute>
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1'
and @level <= $stoppingLevel]">
<li>
<xsl:if test="ps:isInList($currentPage/@path, current()/@id, ',') = 1">
<xsl:attribute name="class">Current</xsl:attribute>
</xsl:if>
<xsl:if test="string(data [@alias='umbracoRedirect']) != ''">
<a class="ExternalLink" href="{data [@alias='umbracoRedirect']}">
<xsl:value-of select="@nodeName" />
</a>
</xsl:if>
<xsl:if test="string(data [@alias='umbracoRedirect']) = ''">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName" />
</a>
</xsl:if>
<xsl:if test="count(./node [string(./data [
@alias='umbracoNaviHide']) != '1'
and @level <= $stoppingLevel
and ps:isInList($currentPage/@path, current()/@id, ',') = 1
]) > 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="." />
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<!-- ============================================================ -->
<msxml:script language="C#" implements-prefix="ps">
<![CDATA[
public bool isInList(string sList, string sFind, string sDelim) {
foreach (string sItem in sList.Split(sDelim.ToCharArray()[0]))
if (sItem == sFind)
return true;
return false;
}
]]>
</msxml:script>
<!-- ============================================================ -->
</xsl:stylesheet>