Variation of templates (styles)

  1. What are styles ?
  2. Define a tag
    1. Get the tag

What are styles ?

A style is a colored variation of a template.
The variation is made of images and css files.

Define a tag

First you should set skin tags.
In the skins/skinName/tags/tag.xml file :

<?xml version="1.0" encoding="UTF-8"?>

<tags>
	<category id="STYLES_PAGES">
		<label i18n="false">Styles</label>
		<description i18n="false"></description>
		<tag id="STYLES_PAGES_BLEU" target="PAGE">
			<label i18n="false">Bleu</label>
			<description i18n="false"></description>
		</tag>
		<tag id="STYLES_PAGES_ROUGE" target="PAGE">
			<label i18n="false">Rouge</label>
			<description i18n="false"></description>
		</tag>
	</category>
</tags>

Get the tag

The tag is in the sitemapinputdata.
To know the style you must find the current page and get back to its first ancestor that has a style (we look for STYLES_PAGES_*)

Add theses lines to your template will create 2 xslt variables

  • $style The name of the style. For example, if the id is STYLES_PAGES_BLEU, the style is BLEU
  • $stylecontext The path to the resources directory of your style. This directory is in your template : resources/styles/STYLENAME.
    <xsl:variable name="stylePrefix">PLUGIN_TAGS_STYLES_PAGES_</xsl:variable>
    <xsl:variable name="style" select="substring(name(/cms/inputData/sitemap//page[@sitemap:current='true']/ancestor-or-self::page[@*[starts-with(name(), $stylePrefix)]] [1]/@*[starts-with(name(), $stylePrefix)]), string-length($stylePrefix)+1)"/>
    <xsl:variable name="stylecontext" select="concat($templatecontext, '/styles/', $style)"/>