Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Created September 13, 2013 08:35
Show Gist options
  • Save andrewminton/6548123 to your computer and use it in GitHub Desktop.
Save andrewminton/6548123 to your computer and use it in GitHub Desktop.
entry Based Navigation for Symphony CMS
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*[section/@handle='pages']/entry" mode='link'>
<xsl:choose>
<xsl:when test="parent/item">
<xsl:apply-templates select='../../navigation/entry[@id=current()/parent/item/@id]' mode='link'/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='$root'/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test='url-title/@handle = "home"'>
</xsl:when>
<xsl:otherwise>
<xsl:text>/</xsl:text><xsl:value-of select="url-title/@handle"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*[section/@handle='pages']/entry" mode='nav'>
<li>
<a>
<xsl:attribute name='href'>
<xsl:apply-templates select='current()' mode='link'/>
</xsl:attribute>
<xsl:value-of select='title'/>
</a>
<!-- if there is a submenu enabled do something -->
<xsl:if test='../entry[parent/item/@id=current()/@id]'>
<ul class="nav">
<xsl:apply-templates select='../entry[parent/item/@id=current()/@id]' mode='nav'/>
</ul>
</xsl:if>
</li>
</xsl:template>
<xsl:template name='navigation'>
<ul>
<xsl:apply-templates select='/data/navigation/entry[not(parent/item)]' mode='nav'/>
</ul>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment