Merge Field Functions
A range of functions are available; functions are like mathematical functions in Microsoft Excel – they take various arguments and produce an output. For example the ‘date’ function allows formatting of dates and formatting and display of the current date.
Examples;
{date(“d/m/Y”)} produces the current date formatted as displayed – if the date was the 3rd of February 2008, this would show; 03/02/2008.
{date(“d/m/Y”, available)} would show the date referred to as ‘available’ (whatever that merge field evaluates to), in the above format.
Function reference;
max
Description: Returns the maximum of a list of numbers.
Options:
Takes a list of numbers or merge field data, e.g.;
Max(5,6,rating)
min
Description: Returns the minimum from a list of numbers.
Options:
Takes a list of numbers or merge field data, e.g.
Min(5,6,rating)
abs
Description: Return the absolute value of a number.
Options:
Takes a simple number, e.g.
Abs(-5)
date
Description: Returns the formatted version of a date.
Options:
- Format string
- date value (optional – assumes current date)
Format of the options is compatible with PHP’s date function details of which can be found here; http://au2.php.net/date
E.g.;
Date(“Y-m-d”)
Date(“Y-m-d”, available)
Functions: minutes, hours, days, months, years
Description:
Returns a number for each of these components of the date.
Options:
Takes the date, e.g.
Days(available)
Minutes(available)
Dates are presented in the internal database format, but can be reformatted any way you like.
So these 4 lines:
{added}
{date(“d/m/Y”, added)}
{date(“d/m/Y H:m”, added)}
{date(“D/M/Y”, added)}
Will produce these 4 outputs:
2009-10-01 13:53:43
01/10/2009
01/10/2009 13:10
Thu/Oct/2009
Note: the editor may change the quotes “to html special encodings which trips up the data merge system. If you have problems with these, edit the HTML directly and put your quotes in there, removing the code (which will look something like ‘"’).
translate
Description: Translates a number into a piece of text.
Options:
- a number or merge field representing which of the next arguments should be displayed.
- or more arguments with what will be displayed.
E.g.
Translate(rating, “1 star”, “2 stars”, “3 stars”)
time function
Description: The UNIX timestamp of a date.
Options:
The date, optional – current date is assumed, e.g.;
Time(available)
lowercase
Description: Changes text to lower case.
Options:
The text to change, e.g.;
Lowercase(“HELLO”);
uppercase
Description: Changes text to upper case.
Options:
The text to change, e.g.
uppercase(“hello”);
substring
Description: Cuts out a section of the string.
Options:
- The string.
- start character zero based.
- length of characters to grab.
E.g.;
Substring(firstname, 0, 1) – this will return the first letter of the first name.
Length
Description: Returns the length of the string.
Options:
The string, e.g.;
Length(firstname)