In a template, it's possible to integrate charter variations. These variations are assigned to pages via charter labels, with only the CSS styles changing. A test in the common XSL checks whether a page, or one of its parent pages, has a charter label. If no charter label is identified, the default style is applied; otherwise, the styles provided by this label are applied. Depending on the number of styles specific to each declination, two methods are possible:
If the style variations are minor and do not justify the import of an additional css , they can be defined in the generic css . Adding a class to the template's body tag will serve as a selector for different color variations, for example.
If style variations are major, it is preferable to import a specific css for each declination, which will override the values defined in the generic css . In this way, the generic css does not include all style variations not used for a given page.
Example of color variations for minor variations:
template.xsl
Oops!
Copy to clipboard failed. Open the code and copy it manually.
<xsl:template name="template">
<html>
<head>
<!-- Contenu du head -->
</head>
<body>
<xsl:attribute name="class">
<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:choose>
<xsl:when test="$style='[styleName1]'">bleu</xsl:when>
<xsl:when test="$style='[styleName2]'">vert</xsl:when>
<xsl:when test="$style='[styleName3]'">rouge</xsl:when>
</xsl:choose>
</xsl:attribute>
<!-- Contenu du body -->
</body>
</html>
</xsl:template>
<xsl:template name="template">
<html>
<head>
<!-- Contenu du head -->
</head>
<body>
<xsl:attribute name="class">
<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:choose>
<xsl:when test="$style='[styleName1]'">bleu</xsl:when>
<xsl:when test="$style='[styleName2]'">vert</xsl:when>
<xsl:when test="$style='[styleName3]'">rouge</xsl:when>
</xsl:choose>
</xsl:attribute>
<!-- Contenu du body -->
</body>
</html>
</xsl:template>
<xsl:template name="template">
<html>
<head>
<!-- Contenu du head -->
</head>
<body>
<xsl:attribute name="class">
<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:choose>
<xsl:when test="$style='[styleName1]'">bleu</xsl:when>
<xsl:when test="$style='[styleName2]'">vert</xsl:when>
<xsl:when test="$style='[styleName3]'">rouge</xsl:when>
</xsl:choose>
</xsl:attribute>
<!-- Contenu du body -->
</body>
</html>
</xsl:template>
Example of color variations for major variations:
Oops!
Copy to clipboard failed. Open the code and copy it manually.