Wherever you are calling out your variables names within DocuMerge (templates, field maps, settings, deliveries, etc) you can use these Data Modifiers to quickly alter the output of the variable.
Modifiers are called after variables, separated by a pipe “|
“. {$price|round}
Some modifiers have additional variables that can be passed, which are defined after the modifier name, and separated by a colon “:
“. {$price|number_format:2:",":"."}
You can use multiple modifiers in a single call. Order of operations is left to right.{$price|round|number_to_words}
Below is our list of Data Modifiers available. For other enabled functions related to PHP, see Operators, Math/Calculations, and Functions.
DATE/TIME
Modifier | Description | Syntax |
---|---|---|
date_format | Change the date format | {$date|date_format:"M/D/Y"} Visit www.php.net/date for more options. |
time_to_words | Number of seconds as text | {$time|time_to_words} |
add_days | Add days to a date value | {$date|add_days:30} |
age | Convert date into years from today | {$birth_date|age} |
age_to_words | Convert date into years, days, hours | {$birth_date|age_to_words} = 12 years 13 days 1 hours |
calendar | Create calendar from dates array | $dates = [{“name”:”Offer Made”, “date”:”08/05/2023″}, {“name”:”Escrow Paid”, “date”:”08/16/2023″}, {“name”:”Property Closed”, “date”:”09/16/2023″}]{json_encode($dates)|calendar} |
NUMBERS
Modifier | Description | Syntax |
---|---|---|
currency_format | Format a currency value | {$amount|currency_format:"$"} 12.99 = $12.99Euro: {$amount|currency_format:"€":2:",":"."} |
round | Round to number of decimal places | {$price|round:2} |
int_number | Convert international number to US format (for calculations) | {$total = $price|int_number + $tax|int_number} |
number | Convert string to a number (for calculations) | {$Total|number} 12,345 = 12345 |
number_eu_to_us | Converts a number from EU to US format | {$price|number_eu_to_us} |
number_us_to_eu | Converts a number from US to EU format | {$price|number_us_to_eu} |
number_format | Change the number format (commas, decimals) | {$total|number_format:2} 1234.5 = 1,234.50Euro & Intl {$total|number_format:2:",":"."} |
number_to_words | Convert number to words | {$total|number_to_words} |
money_to_words | Convert numeric price to words | {$total|money_to_words} 7.50 = seven dollars and fifty cents{$total|money_to_words:"euro"} 5 = five euros |
decimal_to_words | Convert a decimal to written fraction | {$measurement|decimal_to_words} = two and one quarter |
phone_format | Format a phone number | {$home|phone_format:"(%3) %3-%4"} = (123) 456-7890 |
TEXT
Modifier | Description | Syntax |
---|---|---|
lower | Converts characters to lowercase | {$string|lower} |
upper | Converts characters to uppercase | {$string|upper} |
capitalize | Capitalize the first letter | {$last_name|capitalize} |
capitalize_sentences | Capitalize the first word in each sentence | {$paragraph|capitalize_sentences} |
ucfirst | Capitalize the first letter of the first word | {$last_name|ucfirst} |
ucwords | Capitalize the first letter of each word | {$full_name|ucwords} |
count_characters | Returns the number of characters in a string | {$full_name|count_characters} John Doe = 7 {$full_name|count_characters:true} ‘true’ includes whitespaces John Doe = 8 |
cat | Append text to the end of a string | {$first_name|cat:" is very intelligent!"} |
truncate | Shorten string to the given length | {$string|truncate:100} |
replace | Search and replace a string | {$address|replace:"Road":"Rd"} 12 Branch Road = 12 Branch Rd |
strip | Replaces new lines, tabs, and spaces with a space | {$string|strip} |
strip_tags | Remove HTML tags | {$string|strip_tags} |
substr | Create a sub-string from the string, defining start and end | {$string|substr:0:20} |
strpos | Find the position of the first occurrence of a string | {$_position = $string|strpos:"some string"} |
abbreviation | Using 1st letter of each word, converts text to abbreviation | {$full_name|abbreviation:"suffix":"prefix"} {$client_name|abbreviation} Jane Doe = JD{$client_name|abbreviation:"."} Jane Doe = J.D. |
state_abbreviation | Convert US State name to an abbreviation | {$state_name|state_abbreviation} |
spacify | Insert a space or string between each character | {$username|spacifiy} |
translate | Google translate text into another language | {$string|translate:"cz"} |
MISCELLANEOUS
Modifier | Description | Syntax |
---|---|---|
default | Set a default value | {$size|default:"Medium"} |
implode | Convert array values into string with a separator | {implode(", ", $sizes)} = Small, Medium, Large |
csv_to_array | Convert CSV string to an array | {$_newArray = $csv|csv_to_array} |
list array values | List array values and define separators | {$sizes|list:",":"or"} = Small, Medium, or Large |
sort | Sort array by a key; asc (ascending) or desc (decending) | {foreach from=$products|sort:"Name" item=_r} or {foreach from=$products|sort:"Name":"desc" item=_r} |
multisort | Sort an array by multiple keys | {foreach from=$products|multisort:"Name":"desc":"Price":"asc" item=_r} |
insert_image | Inserts an image from an image URL. | {$imgURL|insert_image:200:150} = width 75px, height 50px{$imgURL|insert_image:200:0} = width 75px, height auto{$imgURL|insert_image:75:0:0:50} = width 75px, height auto, max-height 50px{$imgURL|insert_image:0:0:75:50} = width & height auto, max-width 75px, max-height 50px |
bitly | Converts URL to Bitly URL | {$url|bitly:"username":"password"} |
expand_url | Returns actual URL (follow redirects) | {$bitly_url|expand_url} |
parse_url | Search string for a contained URL | {$string|parse_url} |
get_file | Download file from URL | {$_text = $url|get_file} |
xml_safe | Encode data for XML/Office docs | {strftime("%d %B %Y", strtotime($_date))|ucwords|xml_safe} |
html_safe | Convert to HTML safe characters | {$string|html_safe} |
markdown2html | Convert markdown to HTML | {$string|markdown2html} Designed for Markdown format styles: . Italic . Bold . Heading (with html2office Modifier) . Link (with html2office Modifier) |
text2html | Convert text to HTML | {$string|text2html} for use in document builder only |
html2text | Convert HTML to plain text | {$string|html2text} |
html2office | Convert HTML to DOCX format | {$string|html2office} for use in office documents only |
nl2br | Replace new-line characters with HTML <br> line breaks | {$string|nl2br} for use in document builder only |
nl2p | Wrap new-line characters with HTML <p>…</p> paragraph | {$string|nl2p} for use in document builder only |
nl2 | Replace new-line characters with a provided string | {$string|nl2:", "} |
pad | Pad string with a string, so it is the given length | {$vendor_number|pad:10:"0"} 12345 = 0000012345 |