Created
February 14, 2013 21:40
-
-
Save yetanotherchris/4956647 to your computer and use it in GitHub Desktop.
Umbraco XSLT sitemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
exclude-result-prefixes="msxml umbraco.library"> | |
<xsl:output method="xml" omit-xml-declaration="yes"/> | |
<xsl:param name="currentPage"/> | |
<!-- update this variable on how deep your site map should be --> | |
<xsl:variable name="maxLevelForSitemap" select="4"/> | |
<xsl:template match="/"> | |
<div id="sitemap"> | |
<xsl:call-template name="drawNodes"> | |
<xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/> | |
</xsl:call-template> | |
</div> | |
</xsl:template> | |
<xsl:template name="drawNodes"> | |
<xsl:param name="parent"/> | |
<ul> | |
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level" | |
<= $maxLevelForSitemap]"> | |
<li> | |
<a href="{umbraco.library:NiceUrl(@id)}"> | |
<xsl:value-of select="@nodeName"/> | |
</a> - <xsl:value-of select="./data[@alias='dcDescription']"/> | |
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level" | |
<= $maxLevelForSitemap]) > 0"> | |
<xsl:call-template name="drawNodes"> | |
<xsl:with-param name="parent" select="."/> | |
</xsl:call-template> | |
</xsl:if> | |
</li> | |
</xsl:for-each> | |
</ul> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment