Home

Download this help site
(PDF 80MB)

Download

Theme files language syntax

This functionality is only intended for experienced web designers

Icon

Please read this page before you proceed: Advanced customization warning
Theme override is intended for people with advanced web design skills. Incorrect use may result in your website malfunctioning.
Note: our technical support team does not provide support related to theme overrides.

Wild Apricot theme files use a combination of HTML and StringTemplate code.

Here's some brief information on using template language in Wild Apricot themes:

Template variables

There are two ways for variables to be set in your template. (A template is the file containing the actual code for a gadget or other theme component.)

  1. Passing variables as a parameter in a template call.
  2. Using pre-defined variables (or properties).

There are different sets of preset properties for general page templates and for each gadget. You may output template property values by using the following syntax.

For a list of available properties, see Customizing theme gadgets.

Using templates

You can load a template into a page using the following syntax:

This loads TemplateName.tpl located in root folder of your theme. To load template located in Layouts folder e.g. Layouts/Helpful.tpl), use <$Layouts/Helpful()$> instead.

Passing parameters

You can pass parameters to templates by specifying them using the following syntax:

You can specify more then one parameter, separate them with commas like this:

Within the template, you can access parameters passed to it via the following syntax:

This code would output value1 in its place.

You can also pass parameters to make conditional calls to your template (see below).

Using conditional statements

You can use conditional statements to check if a property has been set. For example, you could use the following code to check if a property is true and then return some HTML content:

or you could also check the opposite condition using the ! modifier, for example:

You can use both if and else statements to provide alternate code to be executed depending on the property:

You also can use && (and) and || (or) operands in your expressions:

In this example we add a special class if our page has children. This is live example from one of our templates.

You can also check against strings and numbers, like we do in Social sharing buttons gadget:

In this real-world example we iterate thru our SocialButtons collection (see Iterators just below) and render bits of code based on current item' in collection value.

Using iterators

Sometimes you need to display a collection or a set of elements, such as a list of menu items. To do this, you use iterators to process each item in the collection. For example:

Here ItemsCollectionName is the name of items collection, and IteratorTemplate is a name of .tpl file to be called for every item in the collection. To access the value of each collection item, you use a special template variable it. For example, the following code would output the value of the currently iterated item.

It is sometimes unnecessary to create a separate iterator template for every item collection you want to iterate. In this case, you can create an inline iterator template. For example, the following code would iterate over ItemsCollectionName and output name of every item's Name property:

On this page: 

  • No labels
 
Wild Apricot Inc. 144 Front Street West Suite 725, Toronto, Ontario, Canada M5J 2L7