Reference library

Article number: 310309

Reserved Variable Blocks

Reserved variable blocks are special variable blocks that can be used to access advanced customisations within the CMS.

To use these, you need to create a variable block with the name specified below:

HTTPHeaders (v12)

Any values added to the 'HTTPHeaders' variable block will automatically be added to the HTTP response headers when the page is served on the front-end of your web-site. This can be used to add any HTTP headers that you may require, now or in the future, that are not already handled by the CMS.

HTTP headers must be added to the variable block one header per line, with only a single colon per line. For example, this is how to add some advanced security headers to your pages:

X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self' my-domain.com;

Reserved Variables (v12)

BodyTagAttributes

Any attributes added to the 'BodyTagAttributes' variable will automatically be added to the HTML body tag of each page.

For example, this is how to add a class to every body tag:

class="my-global-body-class"

Customising Front-End Markup Using Variable Blocks (v12)

You can define your own reserved variable blocks that contain templates for customising the HTML output from front-end widgets, such as navigation and search results. These allow you to control precisely what markup will be used on the front-end.

Each controllable front-end component can have a template supplied for an item and the wrapper containing the list of items. See Sitekit: Syntax for the list of components and their syntax.

Each widget has its own set of specific magic words that are needed to customise the output. The following examples show how to use variable blocks to customise front-end markup:

Navigation (Type 6)

You need to create two variable blocks, e.g. 'nav-item-template' and 'nav-list-template':

Variable Block: nav-item-template

<li class="my-li-class">
  <a class="my-a-class" href=":::path:::">:::navtitle:::</a>
  :::items:::
</li>

The full set of magic words that are specific to the navigation item templates are as follows:

Magic WordMeaning
:::items:::This is where sub-lists of navigation items will be placed. Note that this is recursive for navigation.
:::path:::The URL of the nav item for the link.
:::navtitle:::The label of the page.
:::title:::The title of the page.
:::tooltip:::The navigation tooltip.
:::accesskey:::The access key for navigation.
:::active:::A boolean indicating whether this item is active.

Variable Block: nav-list-template

<ul class="my-ul-class">
  :::items:::
</ul>

The full set of magic words that are specific to the navigation list templates are as follows:

Magic WordMeaning
:::items:::This is where sub-lists of navigation items will be placed. Note that this is recursive for navigation.
:::level:::The level of the branch in navigation.

Attaching to a Navigation Menu

The names of these two variable blocks are then passed to the <sitekit:navigation> sniplet like this:

<sitekit:navigation id="Nav1" itemtemplate="nav-item-template" listtemplate="nav-list-template"/>

Search Results

You need to create two variable blocks, e.g. 'search-item-template' and 'search-list-template':

Variable Block: search-item-template

<div data-id=":::shortcutid:::-:::entrykind:::-:::linkid:::-:::assetid:::-:::trackingid:::">
  <h1>
    <a href=":::path:::">:::title:::</a>
  </h1>
  <p>
    :::context:::
  </p>
</div>

The full set of magic words that are specific to the search result item templates are as follows:

Magic WordMeaning
:::id:::Result ID.
:::path:::The URL of the item for the link.
:::title:::The title of the item found.
:::summary:::The summary of the item found.
:::context:::The context where the search terms were found.
:::shorcutid:::The shortcut ID of the asset found.
:::entrykind:::What kind of item is it?
:::linkid:::Link ID of the item found.
:::assetid:::Asset ID of the item found.
:::trackingid:::Tracking ID of the item found.

Variable Block: search-list-template

<div data-index=":::indexid:::" data-terms=":::terms:::">
  :::items:::
</div>

The full set of magic words that are specific to the navigation list templates are as follows:

Magic WordMeaning
:::items:::This is where items found will be placed.
:::indexid:::The id of the search index.
:::terms:::The search terms.

Attaching to a Search Result Block

The names of these two variable blocks are then passed to the <sitekit:searchresults> sniplet like this:

<sitekit:searchresults id="SearchResults1" class="SearchResults" indexname="SiteWide" show="context" itemtemplate="search-item-template"  listtemplate="search-list-template"/>

Downloads

You need to create two variable blocks, e.g. 'downloads-item-template' and 'downloads-list-template':

Variable Block: downloads-item-template

<li><a href=":::path:::">:::title:::</a></li>

The full set of magic words that are specific to the downloads item templates are as follows:

Magic WordMeaning
:::path:::The URL of the download for the link.
:::title:::The title of the download.
:::iconimage:::The icon image for the download. You can use this to add custom icons for files using this URL: //getimage.aspx.ID-:::iconimage:::
:::iconname:::The icon name for the download. You can use this to add default icons for files using this URL: /images/fileicons/:::iconname:::.gif
:::summary:::The summary of the download.
:::shorcutid:::The shortcut ID of the asset found.
:::size:::The size of the file.
:::extension:::The file extension.
:::type:::The file type.

Variable Block: downloads-list-template

<ul>:::items:::</ul>

The full set of magic words that are specific to the downloads list templates are as follows:

Magic WordMeaning
:::items:::This is where items found will be placed.
:::header:::The header of the download block.
:::header:::The footer of the download block.

Attaching to a Downloads Block

The names of these two variable blocks are then passed to the <sitekit:downloads> sniplet like this:

<sitekit:downloads itemtemplate="downloads-item-template" listtemplate="downloads-list-template"/>



Related questions