Formatting/Modifying Data with Modifiers

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…

Image Description

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

ModifierDescriptionSyntax
date_formatChange the date format{$date|date_format:"M/D/Y"}
{strtotime("+ 30 days", strtotime($_date))|date_format:"m/d/Y"}
Visit www.php.net/date for more options.
time_to_wordsNumber of seconds as text{$time|time_to_words}
add_daysAdd days to a date value{$date|add_days:30}
ageConvert date into years from today{$birth_date|age}
age_to_wordsConvert date into years, days, hours{$birth_date|age_to_words}
= 12 years 13 days 1 hours
calendarCreate 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

ModifierDescriptionSyntax
currency_formatFormat a currency value{$amount|currency_format:"$"}
12.99 = $12.99

Euro:
{$amount|currency_format:"€":2:",":"."}
roundRound to number of decimal places{$price|round:2}
{$decimals|round}
int_numberConvert international number to US format (for calculations){$total = $price|int_number + $tax|int_number}
numberConvert string to a number (for calculations){$Total|number}
12,345 = 12345
number_eu_to_usConverts a number from EU to US format{$price|number_eu_to_us}
number_us_to_euConverts a number from US to EU format{$price|number_us_to_eu}
number_formatChange the number format (commas, decimals){$total|number_format:2}
1234.5 = 1,234.50

Euro & Intl
{$total|number_format:2:",":"."}
number_to_wordsConvert number to words{$total|number_to_words}
money_to_wordsConvert 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_wordsConvert a decimal to written fraction{$measurement|decimal_to_words}
= two and one quarter
phone_formatFormat a phone number{$home|phone_format:"(%3) %3-%4"} = (123) 456-7890
{$office|phone_format:"%3.%3.%4"} = 123.456.7890


TEXT

ModifierDescriptionSyntax
lowerConverts characters to lowercase{$string|lower}
upperConverts characters to uppercase{$string|upper}
capitalizeCapitalize the first letter{$last_name|capitalize}
capitalize_sentencesCapitalize the first word in each sentence{$paragraph|capitalize_sentences}
ucfirstCapitalize the first letter of the first word{$last_name|ucfirst}
ucwordsCapitalize the first letter of each word{$full_name|ucwords}
count_charactersReturns 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
catAppend text to the end of a string{$first_name|cat:" is very intelligent!"}
truncateShorten string to the given length{$string|truncate:100}
replaceSearch and replace a string{$address|replace:"Road":"Rd"}
12 Branch Road = 12 Branch Rd
stripReplaces new lines, tabs, and spaces with a space{$string|strip}
strip_tagsRemove HTML tags{$string|strip_tags}
substrCreate a sub-string from the string, defining start and end{$string|substr:0:20}
strposFind the position of the first occurrence of a string{$_position = $string|strpos:"some string"}
abbreviationUsing 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_abbreviationConvert US State name to an abbreviation{$state_name|state_abbreviation}
spacifyInsert a space or string between each character{$username|spacifiy}
{$steps|spacify:"-"}
translateGoogle translate text into another language{$string|translate:"cz"}


MISCELLANEOUS

ModifierDescriptionSyntax
defaultSet a default value{$size|default:"Medium"}
implodeConvert array values into string with a separator{implode(", ", $sizes)}
= Small, Medium, Large
csv_to_arrayConvert CSV string to an array{$_newArray = $csv|csv_to_array}
list array valuesList array values and define separators{$sizes|list:",":"or"}
= Small, Medium, or Large
sortSort 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}
multisortSort an array by multiple keys{foreach from=$products|multisort:"Name":"desc":"Price":"asc" item=_r}
insert_imageInserts 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
bitlyConverts URL to Bitly URL{$url|bitly:"username":"password"}
expand_urlReturns actual URL (follow redirects){$bitly_url|expand_url}
parse_urlSearch string for a contained URL{$string|parse_url}
get_fileDownload file from URL{$_text = $url|get_file}
xml_safeEncode data for XML/Office docs{strftime("%d %B %Y", strtotime($_date))|ucwords|xml_safe}
html_safeConvert to HTML safe characters{$string|html_safe}
markdown2htmlConvert markdown to HTML{$string|markdown2html}
Designed for Markdown format styles:
. Italic
. Bold
. Heading (with html2office Modifier)
. Link (with html2office Modifier)
text2htmlConvert text to HTML{$string|text2html}
for use in document builder only
html2textConvert HTML to plain text{$string|html2text}
html2officeConvert HTML to DOCX format{$string|html2office}
for use in office documents only
nl2brReplace new-line characters with HTML <br> line breaks{$string|nl2br}
for use in document builder only
nl2pWrap new-line characters with HTML <p>…</p> paragraph{$string|nl2p}
for use in document builder only
nl2Replace new-line characters with a provided string{$string|nl2:", "}
padPad string with a string, so it is the given length{$vendor_number|pad:10:"0"}
12345 = 0000012345
Tags: , , ,

Was this article helpful to you?

Yes No

Related Articles