Token transforms
The transforms described below are options available to a number of the text-based tokens, to manipulate the result before it is inserted into your email.
They are applied in the order supplied.
Tokens that accept transforms:
- basket
- basketitem
- datatable
- recipient
- text
lowercase
All alphabetic characters converted to lowercase
uppercase
All alphabetic characters converted to uppercase
ucfirst
Uppercase the first character
ucwords
Uppercase the first character of each word
titlecase
Uppercase the first character of each word, and lowercase every other letter
truncate
This transform requires a value to be given:
truncate=x
Place the required number in place of x, for example:
truncate=2
Truncates text to x characters and appends ..., if the text is longer than x
dateformat
This transform can optionally take a value, which is used as the format code. By default (ie. with no value provided) the format will be: d/m/Y
dateformat=Y-m-d
List of available format codes
Examples
The examples below are based on the original value from a date field of 2010-04-05 10:30:15 :
dateformat => 14/5/2010
dateformat=Y-m-d => 2010-05-14
dateformat=Y-m-d H:i:s => 2010-05-14 10:30:15
datediff
This transform shows the difference between two dates, in number of days. It compares the value of the token with the optional value for the transform. If the transform value is omitted, the current date is used for the comparison. The result will always be a positive whole number.
datediff=x
Place the required comparison date in place of x in the format Y-m-d, for example:
datediff=2013-04-26
Examples
The examples below are based on the original value from a date field of 2013-04-05 10:30:15 and a current date of 2013-04-01 :
datediff => 4
datediff=2013-04-26 => 21
datemod
Use a date modifier to produce a date, from date input in the token value.
datemod=x
Place the required modifier in place of x. The modifier accepts human-readable expressions.
Examples
The examples below are based on the original value from a date field of 2013-04-05 10:30:15 :
datemod=+1 day => 2013-04-06 10:30:15
datemod=-2 weeks => 2013-03-22 10:30:15
datemod=+3 months -6 hours => 2013-07-06 04:30:15
numberformat
By default (ie. with no value provided) this transform will format a number to 2 decimal places, using a period (.) as the decimal separator, and a comma (,) as the thousand separator.
It is possible to alter the number of decimal places by specifying the number of decimal places required, to a maximum of 9, in place of x:
numberformat=x
If a change to the decimal and thousand separators is also required, these can additionally be specified in place of d and t respectively:
numberformat=xdt
Examples
The examples below are based on the original value from a number field of 12345.6789 :
numberformat => 12,345.68
numberformat=3 => 12,345.679
numberformat=3 . => 12.345 679
numberformat="3, " => 12 345,679
Note the use of a comma in the value requires the value to be wrapped in double-quotes.
booleanformat
Transforms a boolean value into alternate true/false values. By default a boolean field outputs 1 or 0.
The option value is specified as the new true and false outputs, separated by a colon. For example:
booleanformat=1:0
booleanformat=true:false
booleanformat=yes:no
htmlencode
All characters which have HTML character entity equivalents are translated into these entities.
urlencode
Encodes and reserved characters for a URL.
noencode
Prevents the use of urlencode
when combined with the static
option for the recipient
token.
nl2br
Inserts HTML line breaks before all newlines.
striptags
Strips HTML tags
md5
Creates an MD5 (Wikipedia) hash of the data.
The transform also takes a value which is used as a salt (Wikipedia). The salt is appended to the data, and the MD5 hash is created from this new value.
sha1
Creates an SHA-1 (Wikipedia) hash of the data.
The transform also takes a value which is used as a salt (Wikipedia). The salt is appended to the data, and the SHA-1 hash is created from this new value.
sha256
Creates an SHA-256 (Wikipedia) hash of the data.
The transform also takes a value which is used as a salt (Wikipedia). The salt is appended to the data, and the SHA-256 hash is created from this new value.
base64
Encode the data as Base64 (Wikipedia).
The transform also takes a value which is used as a salt (Wikipedia). The salt is appended to the data, and the Base64 encoding is created from this new value.
Updated 10 months ago