Template Variables
Template Variables are extra customized fields that allow publish to a template custom fields. We have used TV’s in creating a blog application for “tags”, as well as on a current project where basically every page used the same template except for 2 common properties, for a background image. We have many ways that we could do this, but for the most part this was the quickest solution. For more info on TV’s please see the wiki.
From CSS to Template
First thing we did was move the css properties that we needed to change out of the CSS page, and we moved it into the template:
html { background: HtmlBackground; background-repeat: repeat-x; font-size: 14px; } body { background-image: BannerBackground; background-repeat: no-repeat; background-position: center top; }
Creating a TV HtmlBackground & BannerBackground
Next we created 2 TV’s with the default value set to 1 image in particular. We set it up, for a input type of text, and to access the template we setup before.
With this setup we can quickly add in custom background images, as well as have a default set of images which will be used, if nothing is specified.
Some sample images
The results are that with 1 template we can have as many variations of the background images as we need.
