How can we help you?

Variables in Export Templates

With conditions and variables, outputs can be more specified with greater flexibility when exporting text files and documents. For example, by using variables it is possible to hide information that would otherwise be repeatedly displayed, such as the name of the artist, therefore creating a template that provides a clearer overview.

Example: avoid repetition of details in exports

A variable can be given any name you like, such as artist. It can temporarily contain, for example, the artist name which belongs to the current work. For the next work, this variable can be used in conjunction with a condition to check whether the work also originates from the same artist. If this is the case, the artist’s name does not have to be output again. Once this check has been carried out, the variable is updated for the next run-through.

Template:
[#assign artist = ""] (initially empty variable)
[#list bworks as w]
[#if artist != w.ArtistFirstLast] (check)
${w.ArtistFirstLast}
[/#if]
${w_index + 1}. ${w.Title}, ${w.Year}
[#assign artist = w.ArtistFirstLast] (update)
[/#list]
Example output:
Artist 1
1. Title of work, Year
2. Title of work, Year (same artist: artist not printed)
Artist 2
3. Title of work, Year
Artist 3
4. Title of work, Year

Allocate values to variables

Variables can be imagined as place-holders, the content of which you can define yourself in the template and update and display whenever you like.

These can be specified in any position in an export template, and can be given whatever name you wish. If a template contains a variable that is repeatedly defined with the same name, the existing variable is simply updated with the new value. Later, in the exported document, all definitions are removed.

The keyword #assign in square brackets is used to define the variable, which is also given a name and assigned a value using the equals sign (=).

[#assign VariableName = "value of the variable"]

Please note: generally, the value consists of text, which must be provided in quotation marks. If, however, a number is required, for example in order to compare sizes or prices, then no quotation marks are used. Thousands separators (10,000) also cannot be used in such cases!

Use variables in conditions

In conditions, the variable can be used simply by using its name:

[#assign MaxPrice = 50000]
[#if w.PriceNetValue gt MaxPrice ]
Price upon request
[#else]
${w.PriceNet}
[/#if]

In the example, for prices above (gt, greater than) a certain value (50000) only “Price upon request” is shown.

Hint: if you want to be able to adjust one or more variables in your template, depending on which task is involved, these should be defined at the beginning of the template. This way, for example, you can easily change the maximum value of the price in your template depending on the exhibition in question, without having to look for the variable in the template.

Use variables instead of place-holders

Variables can also be issued directly; this way you can, for example, initially save a very long and complicated place-holder like w.IPriceBaseCurrencyNetValue in a variable with a short name (net) and then use this in the template instead. This means that the readability of templates can be increased, particularly in the case of tables with multiple columns and limited space. As is standard practice in the case of place-holders, the name of the variable is written with an initial dollar sign and inside curly brackets:

[assign net = w.IPriceBaseCurrencyNetValue]
Price EUR: ${net}