Functions on variables / Modifier
There is a list of predefined functions available that you can apply on your locales, unit data, variables. This list is common for all themes. If you want to add a function, please a product evolution request.
Do not add extra spaces or things like that, it may break the variable / functions.
<!-- LOCALE -->
__@@My text@@__ -> __@@crypt()|My text@@__
<!-- Variable -->
#$variable|title$# -> #$variable|crypt()-title$#
<!-- Unit item -->
{{item.name}} --> {{crypt(item.name)}}
<!-- Unit loop -->
#$loop|{events}|{a}|$#
{a.name} -> {crypt(a.name)}
#$/loop|{events}|{a}|$#
base64
Encodes the given string with base64
It can easily be decoded in Javascript with atob()
#$variable|base64()-my_text$#
crypt - Crypt function
Used to crypt email on front-end side (to avoid form recipients email to be directly in the source code)
For forms recipients, we use the function "crypt
" to make sure the email is not visible on the website in the source code.
#$variable|form_recipients$#
#$variable|crypt()-form_recipients$#
format_date - Format Date function
You can use it like this (inside a loop) : {format_date(a.start_date,'%h')}
First arg is the date and second arg is the format of the date.
In this case "%h
" stands for "Abbreviated month name".
You can find all the possible parameters on this page https://www.php.net/manual/en/function.strftime.php
#$loop|{events}|{a}|$#
{format_date(a.start_date,'%h')}
#$/loop|{events}|{a}|$#
Example:
Start date: 2019-03-01 00:00:00
Formated start date (%h
): Mar
Custom format (if inside a CMS variable) (%d %h %Y (%d/%m/%Y)
): 01 Mar 2019 (01/03/2019)
Currently it is not possible to use any space inside the format of the date inside the theme.
So {format_date(a.start_date,'%d %h')}
will not work
htmlentities - Html entities
same as PHP function (Convert all applicable characters to HTML entities)
JSON related functions
json_encode
to do
json_no_quote
to do
'"__@@json_no_quote()|GMS Log in@@__"'
<- Only needed when you have simple quotes + double quotes (like in GP2)
unit_to_json
to do
Example: {unit_to_json(a,"name|short_description|rate")}
(inside a loop)
remove_space - Remove space
Currently, we need a dedicated function to remove spaces, it can not be a generic function for "replace". 01 02 03 becomes 010203
#$variable|remove_space()-text$#
{{remove_space(item.name)}}
resizeimg - Resize Image function
Only available for unit data, not cms variable.
<!-- LOOP SYNTAX -->
#$loop|{room}|{a}| $#
<!-- original image-->
<img src="{a.first_photo.url_standard}" alt="{a.first_photo.alt}">
<!-- resize img -->
<img src="{resizeimg(a.first_photo.url_standard,800)}" alt="{a.first_photo.alt}">
#$/loop|{room}|{a}| $#
<!-- ITEM SYNTAX -->
{{item.first_photo.url_standard}}
{{resizeimg(item.first_photo.url_standard,800)}}
round - Round a number
round (same as PHP function)
striptags - Strip tags
strip_tags (same as PHP function)
trim - Trim text
same as PHP function {trim(a.name)}
or {{trim(item.name)}}
Last updated