Macro Functions
Introductionβ
With the button functions or f(x) you can perform some operations in your conditions and templates.
Conditions Templates
There are some rules to have into account when using these functions:
Functions will be surrounded by
[MACRO][#MACRO]
tag.[MACRO]base64_encode(Lorem ipsum)[#MACRO]
// TG9yZW0gaXBzdW0=Parameters in these functions will be passed using | as separator and leaving no spaces before or after them.
[MACRO]sum(1|2|3)[#MACRO]
// 6Quotes
"
and'
are not needed to pass string parameters.[MACRO]htmlspecialchars(Lorem & ipsum)[#MACRO]
// Lorem & ipsumIf a space is between the parameters separator | | it will be taken as a string parameter.
[MACRO]str_replace(_| |Lorem_ipsum_dolor)[#MACRO]
// Lorem ipsum dolor
Letβs see a brief description and an example of every function you have available in this section:
Stringsβ
Is arrayβ
Checks if the value passed as parameter is an array.
[MACRO]is_array(asdf)[#MACRO]
// 0
Is boolβ
Checks if the value passed as parameter is a boolean.
[MACRO]is_bool(true)[#MACRO]
// 1
Is numericβ
Checks if the value passed as parameter is a number.
[MACRO]is_numeric(5)[#MACRO]
// 1
Is objectβ
Checks if the value passed as parameter is a object.
[MACRO]is_object(array('test'))[#MACRO]
// true
Is stringβ
Checks if the value passed as parameter is a string.
[MACRO]is_string(This is a text)[#MACRO]
// 1
Lowercase firstβ
Makes a stringβs first character lowercase.
[MACRO]lcfirst(Text)[#MACRO]
// text
[MACRO]lcfirst(TEXT)[#MACRO]
// tEXT
Levenshteinβ
Calculates Levenshtein distance between two strings.
[MACRO]levenshtein(Hello World|llo World)[#MACRO]
// 2
[MACRO]levenshtein(Hello World|llo)[#MACRO]
// 8
Left trimβ
Strips whitespaces (or other characters) from the beginning of a string.
[MACRO]ltrim( Lorem ipsum dolor sit amet)[#MACRO]
// Lorem ipsum dolor sit amet
[MACRO]ltrim(---Lorem ipsum dolor sit amet|-)[#MACRO]
// Lorem ipsum dolor sit amet
[MACRO]ltrim(-_-_Lorem ipsum dolor sit amet|_-)[#MACRO]
// Lorem ipsum dolor sit amet
Weβve inserted some spaces on the left in the first example.
Preg replaceβ
Searchs with regular expression and replaces.
[MACRO]preg_replace(/london/i|New York|visit London)[#MACRO]
// visit New York
Remove break linesβ
Merges the text passed as parameter in one line.
[MACRO]remove_break_lines(
lorem
ipsum
dolor)[#MACRO]
// loremipsumdolor
Right trimβ
Strips whitespaces (or other characters) from the end of a string.
[MACRO]rtrim(Lorem ipsum dolor sit amet )[#MACRO]
// Lorem ipsum dolor sit amet
[MACRO]rtrim(Lorem ipsum dolor sit amet---|-)[#MACRO]
// Lorem ipsum dolor sit amet
[MACRO]rtrim(Lorem ipsum dolor sit amet-_-_|_-)[#MACRO]
// Lorem ipsum dolor sit amet
Weβve inserted some spaces at right in the first example.
Similar textβ
Calculates the similarity between two strings.
[MACRO]similar_text(lorem|lorem)[#MACRO]
// 100
[MACRO]similar_text(lorem|ipsum)[#MACRO]
// 20
Randomβ
Generates random values.
[MACRO]special_random(red#sun|9|LIST)[#MACRO]
// sunsunred
[MACRO]special_random(|5|ALL)[#MACRO]
// 6qA5*
[MACRO]special_random(|15|NUMBERS)[#MACRO]
// 618774390883773
[MACRO]special_random(abc|10|CUSTOM)[#MACRO]
// baabbcbaab
The first argument is only taken into account when the third one is "CUSTOM". It randomizes using the first argument's characters.
String padβ
Pads a string to a certain length with another string.
[MACRO]str_pad(Text|10)[#MACRO]
// Text
[MACRO]str_pad(Text|10|-=|STR_PAD_LEFT)[#MACRO]
// -=-=-=Text
[MACRO]str_pad(Text|10|_|STR_PAD_BOTH)[#MACRO]
// ___Text___
Notice that first output comes with spaces at right.
String repeatβ
Repeats a string.
[MACRO]str_repeat(Text|3)[#MACRO]
// TextTextText
String replaceβ
Replaces all occurrences of the search string with the replacement string.
[MACRO]str_replace(-|_|lorem-ipsum-dolor)[#MACRO]
// lorem_ipsum_dolor
String shuffleβ
Randomly shuffles a string.
[MACRO]str_shuffle(lorem ipsum dolor)[#MACRO]
// d romlisrpomou el
String to objectβ
Converts a string to a object.
[MACRO]str_to_object({"Peter":35,"Ben":37,"Joe":43})[#MACRO]
// {"Peter":35,"Ben":37,"Joe":43}
String case-insensitive positionβ
Finds the position of the first occurrence of a case-insensitive substring in a string.
[MACRO]stripos(aba ABA aba|b)[#MACRO]
// 1
[MACRO]stripos(aba ABA aba|b|3)[#MACRO]
// 5
String lengthβ
Returns the length of the given string.
[MACRO]strlen("adsf sdf")[#MACRO]
// 10
[MACRO]strlen(lorem ipsum...)[#MACRO]
// 14
String positionβ
Finds the position of the first occurrence of a substring in a string.
[MACRO]strpos(aba ABA aba|b)[#MACRO]
// 1
[MACRO]strpos(aba ABA aba|b|3)[#MACRO]
// 9
String to lowerβ
Makes a string lowercase.
[MACRO]strtolower(TEXT)[#MACRO]
// text
String to upperβ
Makes a string uppercase.
[MACRO]strtoupper(text)[#MACRO]
// TEXT
String containsβ
Determine if a string contains a given substring
[MACRO]str_contains(Lorem ipsum dolor sit amet|sit )[#MACRO]
// true
String starts withβ
Checks if a string starts with a given substring
[MACRO]str_starts_with(Lorem ipsum dolor sit amet|Lorem)[#MACRO]
// true
String ends withβ
Checks if a string ends with a given substring
[MACRO]str_ends_with(Lorem ipsum dolor sit amet|amet)[#MACRO]
// true
Substringβ
Returns part of a string.
[MACRO]substr(lorem ipsum dolor|6|5)[#MACRO]
// ipsum
[MACRO]substr(lorem ipsum dolor|-8)[#MACRO]
// um dolor
[MACRO]substr(lorem ipsum dolor|2)[#MACRO]
// rem ipsum dolor
Trimβ
Strips whitespaces (or other characters) from the beginning and end of a string.
[MACRO]trim( Lorem ipsum dolor sit amet )[#MACRO]
// Lorem ipsum dolor sit amet
[MACRO]trim(---Lorem ipsum dolor sit amet___|-_)[#MACRO]
// Lorem ipsum dolor sit amet
Weβve inserted some spaces on the right and left in the first example.
Uppercase firstβ
Makes a stringβs first character uppercase.
[MACRO]ucfirst(text)[#MACRO]
// Text
Uppercase wordsβ
Convert the first character of each word in a string to uppercase.
Parametersβ
string: This is the text string that you want to convert. Each word in the string will have its first letter converted to uppercase.
delimiters: This is an optional parameter. It is a list of one or more characters that specifies the points where the string will be split into words.
[MACRO]ucwords(lorem ipsum dolor| )[#MACRO]
// Lorem Ipsum Dolor
[MACRO]ucwords(lorem-ipsum-dolor|-)[#MACRO]
// Lorem-Ipsum-Dolor
The second parameter of the first function is a space character, and for the second function, it is a hyphen character.
Strip_tagsβ
Strip_tags() is a function that allows you to strip out all HTML tags from a given string.
[MACRO]strip_tags(<p>Lorem ipsum dolor</p>)[#MACRO]
// Lorem ipsum dolor
Dateβ
Dateβ
Formats a local time/date. Visit this link for a complete guide of the supported characters for the format.
[MACRO]date(Y-m-d H:i:s)[#MACRO]
// 2020-10-08 16:57:46
[MACRO]date(j M Y)[#MACRO]
// 8 Oct 2020
Date addβ
Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object. More information in this link.
[MACRO]date_add(01-01-2000|P10D|d-m-Y)[#MACRO] // Adding 10 days
// 11-01-2000
[MACRO]date_add(01-01-2000|P1M|d-m-Y)[#MACRO] // Adding 1 month
// 01-02-2000
[MACRO]date_add(01-01-2000 00:00:00|PT1S|d-m-Y H:i:s|Europe/Amsterdam)[#MACRO] // Adding 1 second
// 01-01-2000 00:00:01
[MACRO]date_add(01-01-2000 00:00:00|PT6H|d-m-Y H:i:s|Europe/Amsterdam)[#MACRO] // Adding 6 hours
// 01-01-2000 06:00:00
Date diffβ
Returns the difference between two DateTime objects.
[MACRO]date_diff(11-01-2000|01-02-2000|%R%a days)[#MACRO]
// +21 days
Date formatβ
Outputs a datetime with a given format. Visit this link for a complete guide of the supported characterss for the format.
[MACRO]date_format("2018-06-02 12:00:00"|"Y-m-d"|"Europe/London")[#MACRO]
// 2018-06-02
[MACRO]date_format(@system.date.universal_datetime@|"d M Y H:i"|"Europe/London")[#MACRO]
// 07 Jun 2018 16:05
Date format with languageβ
Outputs a datetime with a given format in a specific language. Find here the characters supported for the input format and here the strings supported for the output.
[MACRO]date_format_lang(@system.date.universal_datetime@|"Y-m-d H:i:s"|"Europe/London"|"en_us"|"MMMM dd, y HH:mm:ss"|"America/Chicago")[#MACRO]
// June 07, 2018 11:08:07
Date subβ
Subtract an amount of days, months, years, hours, minutes and seconds from a DateTime object.
[MACRO]date_sub(11-01-2000|P10D|d-m-Y)[#MACRO] // Subtracting 10 days
// 01-01-2000
[MACRO]date_sub(01-03-2000|P1M|d-m-Y)[#MACRO] //Subtracting 1 month
// 01-02-2000
Date to timestampβ
Converts a specified date into a timestamp.
[MACRO]date_to_timestamp(Dinsdag 12 augustus 2019|EEEE dd MMMM yyyy|nl_nl|Europe/Madrid)[#MACRO]
// 1565560800
[MACRO]date(Y-m-d H:i:s| 1565560800)[#MACRO]
// 2019-08-12 00:00:00
[MACRO]date_to_timestamp(Dinsdag 12 augustus 2019|EEEE dd MMMM yyyy|nl_nl|Europe/Madrid)[#MACRO]
// 1565560800
[MACRO]date_format_lang(1565560800|U|Europe/Amsterdam|es_es|d MMMM y|Europe/Madrid)[#MACRO]
// 12 agosto 2019
Standard ISO date and time format specifiersβ
Format Character | Description | Example Returned Values |
---|---|---|
Day | ||
d | Day of the month, 2 digits with leading zeros | 01 to 31 |
D | A textual representation of a day, three letters (always in English) | Mon through Sun |
j | Day of the month without leading zeros | 1 to 31 |
l | A full textual representation of the day of the week (always in English) | Sunday through Saturday |
N | ISO-8601 numeric representation of the day of the week | 1 (for Monday) through 7 (for Sunday) |
S | English ordinal suffix for the day of the month, 2 characters | st, nd, rd or th. Works well with j |
w | Numeric representation of the day of the week | 0 (for Sunday) through 6 (for Saturday) |
z | The day of the year (starting from 0) | 0 through 365 |
Week | ||
W | ISO-8601 week number of year, weeks starting on Monday | Example: 42 (the 42nd week in the year) |
Month | ||
F | A full textual representation of a month, such as January or March (always in English) | January through December |
m | Numeric representation of a month, with leading zeros | 01 through 12 |
M | A short textual representation of a month, three letters (always in English) | Jan through Dec |
n | Numeric representation of a month, without leading zeros | 1 through 12 |
t | Number of days in the given month | 28 through 31 |
Year | ||
L | Whether it's a leap year | 1 if it is a leap year, 0 otherwise. |
o | ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. | Examples: 1999 or 2003 |
Y | A full numeric representation of a year, 4 digits | Examples: 1999 or 2003 |
y | A two digit representation of a year | Examples: 99 or 03 |
Time | ||
a | Lowercase Ante meridiem and Post meridiem | am or pm |
A | Uppercase Ante meridiem and Post meridiem | AM or PM |
B | Swatch Internet time | 000 through 999 |
g | 12-hour format of an hour without leading zeros | 1 through 12 |
G | 24-hour format of an hour without leading zeros | 0 through 23 |
h | 12-hour format of an hour with leading zeros | 01 through 12 |
H | 24-hour format of an hour with leading zeros | 00 through 23 |
i | Minutes with leading zeros | 00 to 59 |
s | Seconds, with leading zeros | 00 through 59 |
u | Microseconds | Example: 654321 |
Timezone | ||
e | Timezone identifier | Examples: UTC, GMT, Atlantic/Azores |
I (capital i) | Whether or not the date is in daylight saving time | 1 if Daylight Saving Time, 0 otherwise. |
O | Difference to Greenwich time (GMT) in hours | Example: +0200 |
P | Difference to Greenwich time (GMT) with colon between hours and minutes | Example: +02:00 |
T | Timezone abbreviation | Examples: EST, MDT ... |
Z | Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. | -43200 through 50400 |
Full Date/Time | ||
c | ISO 8601 date | 2004-02-12T15:19:21+00:00 |
r | Β» RFC 2822 formatted date | Example: Thu, 21 Dec 2000 16:01:07 +0200 |
U | Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | 1335939007 |
Mathβ
Divisionβ
Divides all values passed as parameters.
[MACRO]division(100|50|60)[#MACRO]
// 0.033333333333333
Eval spreadsheet formulaβ
Evaluates a spreadsheet formula.
[MACRO]eval_spreadsheet_formula(SUM(1,2))[#MACRO]
// 3
Use english function names, . as decimal separator, , as function argument separator and ; as matrix row separator.
Hexadecimal to binaryβ
Decodes a hexadecimally encoded binary string.
[MACRO]hex2bin(6578616d706c65206865782064617461)[#MACRO]
// example hex data
Multiplyβ
Multiplies all values passed as parameters.
[MACRO]multiply(100|50|60)[#MACRO]
// 300000
Number formatβ
Formats a number with grouped thousands.
[MACRO]number_format(1234.5687|2|,|.)[#MACRO]
// 1.234,57
Oppositeβ
Calculates the positive value if the param is negative and inverse.
[MACRO]opposite(-5)[#MACRO]
// 5
Roundβ
Rounds a number.
[MACRO]round(15.727845677|3)[#MACRO]
// 15.728
Randomβ
Generates random values.
[MACRO]special_random(red#sun|9|LIST)[#MACRO]
// redredredredsunredredsunred
[MACRO]special_random(|5|ALL)[#MACRO]
// 6qA5*
[MACRO]special_random(|15|NUMBERS)[#MACRO]
// 618774390883773
[MACRO]special_random(abc|10|CUSTOM)[#MACRO]
// baabbcbaab
Subtractβ
Subtracts all numbers passed as parameters.
[MACRO]subtract(100|50|60)[#MACRO]
// -10
Sumβ
Sums all numbers passed as parameters.
[MACRO]sum(100|50|60)[#MACRO]
// 210
Encodingβ
Base64 decodeβ
Decodes a MIME base64 encoded data.
[MACRO]base64_decode(bXljb2Rl)[#MACRO]
// mycode
Base64 encodeβ
Encodes the given data with MIME base64.
[MACRO]base64_encode(mycode)[#MACRO]
// bXljb2Rl
Get public URLβ
Outputs a URL to access a file from the file manager.
[MACRO]get_public_url(path/to/file.txt)[#MACRO]
// https://demo.flowize.com/assets/flushfile/file.txt?uri=n8mJsBYXP68K3LguY9Krs0c2VdpKw
[MACRO]get_public_url(path/to/file.txt|https://flow.mycompany.com)[#MACRO]
// https://flow.mycompany.com/assets/flushfile/file.txt?uri=n8mJsBYXP68K3LguY9Krs0c2VdpKw
JSON decodeβ
Takes a JSON encoded string and converts it into a PHP variable.
[MACRO]json_decode({"a":1,"b":2,"c":3})[#MACRO]
// object(stdClass)[1]
// public 'a' => int 1
// public 'b' => int 2
// public 'c' => int 3
JSON encodeβ
Returns a string containing the JSON representation of value. This function will process non-associative and associative arrays but not multidimensional ones.
[MACRO]json_encode(array('a' => 1, 'b' => 2, 'c' => 3))[#MACRO]
// {"a":1,"b":2,"c":3}
The output actually is a PHP variable so weβve run var_dump() to have a represntation of it.
JSON to XMLβ
Converts a JSON structure into an XML structure.
[MACRO]json_xml({'name':'My Widget','widget':{'window':{'width':500,'height':500},'image':{'src':'Images/Sun.png','name':'sun1'},'text':'data':'Click Here','size':36}}})[#MACRO]
// <?xml version="1.0" encoding="UTF-8"?>
//<root>
// <name>My Widget</name>
// <widget>
// <window>
// <width>500</width>
// <height>500</height>
// </window>
// <image>
// <src>Images/Sun.png</src>
// <name>sun1</name>
// </image>
// <text>
// <data>Click Here</data>
// <size>36</size>
// </text>
// </widget>
//</root>
Mb convert encodingβ
Convert character encoding
[MACRO]mb_convert_encoding(mΓΊsica|UTF-7)[#MACRO]
// m+APo-sica
XML to JSONβ
Converts an XML structure into a JSON structure.
[MACRO]xml_json(
<?xml version="1.0" encoding="UTF-8"?>
<root>
<name>My Widget</name>
<widget>
<window>
<width>500</width>
<height>500</height>
</window>
<image>
<src>Images/Sun.png</src>
<name>sun1</name>
</image>
<text>
<data>Click Here</data>
<size>36</size>
</text>
</widget>
</root>
)[#MACRO]
// {
// "name":"My Widget",
// "widget":{
// "window":{
// "width":"500",
// "height":"500"
// },
// "image":{
// "src":"Images/Sun.png",
// "name":"sun1"
// },
// "text":{
// "data":"Click Here",
// "size":"36"
// }
// }
// }
HTMLβ
Decode entitiesβ
Converts all HTML entities to their applicable characters.
[MACRO]html_entity_decode(<b>Bold text</b>)[#MACRO]
// <b>Bold text</b>
Encode entitiesβ
Converts all applicable characters to HTML entities.
[MACRO]htmlentities(<b>Bold text</b>)[#MACRO]
// <b>Bold text</b>
Specialcharsβ
Converts special characters to HTML entities.
[MACRO]htmlspecialchars(Ampersands & double quote " less < and grater > than)[#MACRO]
// Ampersands & double quote " less < and grater > than
Specialchars decodeβ
Converts special HTML entities back to characters.
[MACRO]htmlspecialchars_decode(Ampersands & double quote " less < and grater > than)[#MACRO]
// Ampersands & double quote " less < and grater > than
nl to brβ
Inserts HTML line breaks before all newlines in a string.
[MACRO]nl2br(This
string
in
lines)[#MACRO]
// This<br>
// string<br>
// in<br>
// lines
URL decodeβ
Decodes URL-encoded string (decodes any %## encoding in the given string, plus symbols β+β are decoded to a space character).
[MACRO]urldecode(http%3A%2F%2Fdomain.com%2Fdir%3Fa%3Dsome+text%26b%3Dother)[#MACRO]
// http://domain.com/dir?a=some text&b=other
URL encodeβ
URL-encodes strings, useful when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.
[MACRO]urlencode(http://domain.com/dir?a=some text&b=other)[#MACRO]
// http%3A%2F%2Fdomain.com%2Fdir%3Fa%3Dsome+text%26b%3Dother
Encryptingβ
crc32β
Calculates the crc32 polynomial of a string.
[MACRO]crc32(Lorem ipsum dolor)[#MACRO]
// 1317584614
Cryptβ
One-way string hashing.
[MACRO]crypt(Lorem ipsum dolor|a6dhgf67)[#MACRO]
// $2y$12$Au8efpLLlx6cxGQYEq09heruPW59zVclFNwxe.QQfQ3ov9.xJYNZ6
Hash hmacβ
Hash value using the HMAC method
[MACRO]hash_hmac(ripemd160|The quick brown fox jumped over the lazy dog|secret)[#MACRO]
// 9880cc6f27e5510f1e0dcb95f47074f9ade83106
MD5β
Calculates the md5 hash of a string.
[MACRO]md5(Lorem ipsum dolor)[#MACRO]
// 06ce95ac476fc656cea3fca5d02cfd81
Sha1β
Calculates the sha1 hash of a string.
[MACRO]sha1(Lorem ipsum dolor)[#MACRO]
// 45f75b844bu4d17b3894c6701768daf39419c99b
Compressingβ
Inflateβ
This function inflates a deflated string.
[MACRO]inflate(88kvSs1VyCwoLs1VSMnPyS8CAA==)[#MACRO]
// Lorem ipsum dolor
Deflateβ
This function compresses the given string using the DEFLATE data format. The level of compression. Can be given as 0 for no compression up to 9 for maximum compression.
[MACRO]deflate(Lorem ipsum dolor|6)[#MACRO]
// 88kvSs1VyCwoLs1VSMnPyS8CAA==
Compressβ
This function compresses the given string using the ZLIB data format. The level of compression. Can be given as 0 for no compression up to 9 for maximum compression.
[MACRO]compress(Lorem ipsum dolor|6)[#MACRO]
// eJzzyS9KzVXILCguzVVIyc/JLwIAOd8Gjg==
Uncompressβ
This function uncompress a compressed string.
[MACRO]uncompress(eJzzyS9KzVXILCguzVVIyc/JLwIAOd8Gjg==)[#MACRO]
// Lorem ipsum dolor