Magnolia 5.3 reached end of life on June 30, 2017. This branch is no longer supported, see End-of-life policy.

Page tree
Skip to end of metadata
Go to start of metadata

Variations can be used in a number of ways, for example to reformat content for devices like smartphones and tablets, or specific output for groups of logged in users. See Mobile for a full discussion of the example smartphone variation used in the demo sites and Channels for more information about this core functionality.

Variations are typically configured in the site definition, but can also be configured on a template level in the template definition. See how a variation is used to disable the stage area for smartphones.

(warning) 4.5.3+ In a page template, you can configure a variation that is triggered by the page URL extension. This type of variation cannot be configured in the site definition. In this example, the newsletter variation disables the sectionHeaderextraspromos and base areas, leaving only the main content. You could use such a variation for an online version of a newsletter or a printable version of a page.

Node nameValue
 pages 

 stkSection

 

 areas

 

 variations

 

 newsletter

 

 areas

 

 sectionHeader

 

 enabled

false

 extras

 

 enabled

false

 promos

 

 enabled

false

 base

 

 enabled

false

If you request content on any page based on the stkSection template and change the extension from .html to .newsletter the variation content is served.

You can combine this with the smartphone variation configured in the site definition by adding the ?mgnlChannel=smartphone URL parameter to serve the newsletter variation in a format suitable for smartphones.

Variations are resolved by DefaultRenderableVariationResolver that combines ChannelVariationResolver and ExtensionVariationResolver.

Be careful about using variations to restrict content to specific user groups. Simply changing the URL extension allows other users to see the content. Variation is not a secure mechanism. If used for sensitive content, consider extending DefaultRenderableVariationResolver to provide additional security measures.

CSS and JavaScript

You can also reference template-specific CSS sheets and JavaScripts for individual templates in the template definition. This option could be useful for example for holiday campaigns or dedicated sections of a site.

The example configuration below assigns a specific CSS sheet and an additional JavaScript to the stkArticle template.

Node nameValue
 pages 

 stkArticle

 

 cssFiles

 

 articleStyles

 

 farFutureCaching

true

 link

/resources/templating-kit/css/articleStyles.css

 media

screen

 jsFiles

 

 fireworks

 

 farFutureCaching

true

 link

/resources/templating-kit/js/fireworks.js

1 Comment

  1. This page should be updated to the 5.7 and 6.1 documentation spaces...