XSL for Site navigation in Cascade Server

On moving to Cascade Server 6 we started migrating our sites (in the Global area) to Sites. One of the things we ran into was the base folder is no longer indexed by the XML so getting the top of the tree to show up requires some tinkering with the XSL.

@karf0 fixed our XSL and wanted me to mention the default page will need a display name for the link back to the Home since the base folder is no longer indexed in the XML.  Here is the file for download:  Cascade Site Nav XSL, and the code is also displayed below. There are obviously some code in here that is specific to us (specifically the pngfix class). Also note @karf0's comment at the bottom.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html"/>
	<xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>
	<xsl:variable name="folder-root-page-name">default</xsl:variable>
	<xsl:template match="/system-index-block">
		<ul>
			<li class="active">
				<div class="pngfix">
					<a href="/{$folder-root-page-name}"><xsl:value-of select="system-page[name=$folder-root-page-name]/display-name"/></a>
					<ul>
						<xsl:apply-templates select="system-page[name != $folder-root-page-name] | system-symlink | system-folder"/>
					</ul>
				</div>
			</li>
		</ul>
	</xsl:template>
	<xsl:template match="system-folder">
		<xsl:if test="dynamic-metadata[name = 'nav_exclude' and value = 'Yes']">
			<li>
				<xsl:if test="descendant::system-page[@current='true']">
					<xsl:attribute name="class">active</xsl:attribute>
				</xsl:if>
				<div>
            		<xsl:attribute name="class">pngfix</xsl:attribute>
					<a>
						<xsl:attribute name="href">
							<xsl:value-of select="path"/>/<xsl:value-of select="$folder-root-page-name"/>
						</xsl:attribute>
					<xsl:value-of select="display-name"/>
					</a>
					<ul>
						<xsl:apply-templates select="system-page[name != $folder-root-page-name] | system-symlink | system-folder"/>
					</ul>
				</div>
			</li>
		</xsl:if>
	</xsl:template>
	<xsl:template match="system-page">
		<xsl:if test="dynamic-metadata[name = 'nav_exclude' and value = 'Yes']">
			<li>
				<xsl:choose>
					<xsl:when test="@current='true'">
						<xsl:attribute name="class">activepage pngfix</xsl:attribute>
					  </xsl:when>
				</xsl:choose>
				<a>
					<xsl:attribute name="href">
						<xsl:value-of select="path"/>
					</xsl:attribute>
					<xsl:value-of select="display-name"/>
				</a>
			</li>
		</xsl:if>
	</xsl:template>
	<xsl:template match="system-symlink">
		<li class="external">
			<a>
				<xsl:attribute name="href">
					<xsl:value-of select="link"/>
				</xsl:attribute>
				<xsl:value-of select="display-name"/>
			</a>
		</li>
	</xsl:template>
</xsl:stylesheet>

This entry was posted on Tuesday, September 29th, 2009 at 6:21 am and is filed under Web Finds. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “XSL for Site navigation in Cascade Server”

  1. Karf says:

    As an addendum, the index block must be set to “Start at the current page with folder hierarchy, and also include siblings” in order for this XSL to fully work. The ul’s and li’s on the end product are a little sloppy at the moment and I hope to get time to clean it up in the future.

Leave a Reply