Skip to content

Instantly share code, notes, and snippets.

@designermonkey
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save designermonkey/10837549 to your computer and use it in GitHub Desktop.

Select an option

Save designermonkey/10837549 to your computer and use it in GitHub Desktop.
Using this method, pages can be selected from a selectbox in Symphony, and output into the entry you want to match against. Then a template needs to be created for each option in the selectbox, and the xsl will match against it. Caveats are that the entry needs to be manually passed to the template, as root context is broken.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
Pages Section Templates
Templates for the display of content from the Symphony 'Pages' Section
This is a slightly hacky technique to allow the template to be chosen in the XML.
Pages are driven by content templates, so the mode for each view should reference a content template
xPath: *[section/@handle = 'pages']/entry
@author John Porter <jporter@buginteractive.com>
-->
<!--
Create a variable of this document's templates
-->
<xsl:variable name="content-templates" select="document('')/*/xsl:template[@name]"/>
<!--
Page Entry as a List item
-->
<xsl:template match="*[section/@handle = 'pages']/entry">
<xsl:apply-templates select="$content-templates[@name = current()/template/item/@handle]">
<xsl:with-param name="entry" select="."/>
</xsl:apply-templates>
</xsl:template>
<!--
Content Template: Content Page
The word 'content' must be the output of the selectbox in the section
A template for displaying a visually rich content article
-->
<xsl:template match="xsl:template[@name = 'content']" name="content">
<!-- The entry node must be passed in to the template -->
<xsl:param name="entry"/>
</xsl:template>
<!--
Another Template: Different Page
The word 'another' must be the output of the selectbox in the section
A template for displaying a visually rich content article
-->
<xsl:template match="xsl:template[@name = 'another']" name="another">
<!-- The entry node must be passed in to the template -->
<xsl:param name="entry"/>
</xsl:template>
</xsl:stylesheet>
@nitriques
Copy link

would just match="entry[template = 'sbl-value']" be better ? I use this a lot...

@designermonkey
Copy link
Author

I don't know what you mean. Can you show me an example?

@designermonkey
Copy link
Author

@nitriques do you mean something like:

*[section/@handle = 'pages']/entry[template/item/@handle = 'about']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment