Implementing run-time versioning for Elements


Using System Settings

<script type="text/javascript" src="//[[++jquery_version:default=`1.7.1`]]/jquery.min.js"></script>
<script type="text/javascript" src="//[[++jquerytools_version:default=`1.2.6`]]/all/"></script>


[[++jquery_load:eq=`0`:then=``:else=`DO SOMETHING`]]
[[++jquerytools_load:eq=`0`:then=``:else=`DO SOMETHING`]]
  • » Check for the existence of a System Setting: jquery_load, jquerytools_load
  • » If found check its value to see if it is disabled
  • » If the System Setting does not exist or is set to disabled an empty string is returned
  • » Otherwise the else clause is executed
<script type="text/javascript"
  • » Check for the jquery_version System Setting
  • » If it exists, insert its value in the placeholder
  • » Else default to version 1.7.1


<script type="text/javascript" src="//">
<script type="text/javascript" src="//">


As you may have noticed, the jQuery version which was placed in the page was 1.7.2 and not the default 1.7.1 which was the "current" version when the site went live. This is due to existence of a System Setting which is used to override the default value.

Techniques such as this, allows a single Chunk to be used across multiple Templates and/or Resources in order to update various sections of the site, while leaving others set to the default value.

Most applications would simply place this in the header of a Template and allow the inclusion of the respective library to be managed site-wide - wherever the Template is in use.

Other applications may have very little need of the jQuery library, and therefore the inclusion of a Chunk on those pages may prove more beneficial.

Using a simple Chunk

<script type="text/javascript" src="//[[+jquery_version:default=`1.7.1`]]/jquery.min.js"></script>
<script type="text/javascript" src="//[[+jquerytools_version:default=`1.2.6`]]/all/"></script>


  • » [[++jquery_version:default=`1.7.1`]] becomes [[+jquery_version:default=`1.7.1`]]
  • » Essentially, this simple change makes jquery_version a Placeholder

As this method may be considered more premeditated, the check for it being "desired" in the current page has been removed.

Chunk Call - jQuery Version


Chunk Output

<script type="text/javascript" src="//">
<script type="text/javascript" src="//">

Chunk Call- both changed


Chunk Output

<script type="text/javascript" src="//">
<script type="text/javascript" src="//">

Final Comments

These techniques can be used in a wide array of application, such as layout, targeted css, SEO, images, etc. In many situations similar implementations are the reason the page source changes upon every load. Experiment and see what you can come up with.