Keyword Modifiers

Keyword replacements can be modified using a variety of keyword modifiers to further configure the returned values. These modifiers are represented as extensions added to existing standard keyword replacements, denoted by a caret (^) character followed by the modifier keyword and any necessary modifier arguments. For example, if the keyword replacement %asset_contents^maxwords:10% was used, the first ten words of the body of the asset will be displayed.  

Multiple modifiers can be used on a single keyword replacement, separated by the caret character. For example, %item_price^subtract:2^multiply:10%. This keyword replacement would subtract two from the item price value before multiplying the new value by ten.

The keyword modifiers available are as follows:

Keyword Modifier   Operation  
abs   Displays the absolute value of a returned numerical value.

Example: 
%asset_version^abs%
Effect: 0.2.220 > 0.2
add:<numeral>     Adds a set numeral argument to a returned numerical value.

Example:
 %asset_assetid^add:10%
Effect: 129 > 139
as_asset:<asset_keyword>     Dynamically supplies an asset ID on a set asset_keyword.

Example:
%asset_assetid^as_asset:asset_name%
E
ffect: The name of the asset whose ID is supplied by the asset_assetid keyword replacement.

Example:
%order_number^as_asset:asset_attribute_delivery_addr%
Effect: The delivery address of the order asset whose ID is supplied by the order_number keyword replacement.
base64decode   Decodes data from a returned base64 string.
base64encode   Encodes returned data to a base64 string.
capitalize   Capitalises the first character of a returned value.

Example:
 %asset_name^capitalize%
Effect: home page > Home page
cdata   Wraps a returned value in a CDATA block. This modifier will handle escaping CDATA when CDATA is already supplied.

Example:
 %asset_contents^cdata%
Effect: <![CDATA[asset contents     ]]>
ceil    Rounds a returned numerical value up to the nearest whole integer.
 
Example: %item_price^ceil%
Effect: 8.67 > 9
charcount     Determines the character count of a returned value.
 
Example: %asset_short_name^charcount%
Effect: documents > 9
contains:<string:YES:NO>     Tests if a specified string argument appears in the returned value, returning the number of recurrences. Append the YES and NO arguments for a specified yes or no response.
 
Example: %asset_name^contains:M%
Effect: Squiz Matrix > 1

Example:
%asset_name^contains:M:Found:Not Found%
Effect: Squiz Matrix > Found

Example:
%asset_name^contains:B:Found:Not Found%
Effect: Squiz Matrix > Not Found 
context:<context>     Sources the returned value from the specified context.

Example:
%asset_name^context:French%
Effect: Returns the asset name in the French context, eg. Page d'accueil.
date_format:<format> Formats a returned date string value to a set PHP date format argument.

Example:
 %asset_created^date_format:Y%
Effect: 2010-03-03 10:00:00 > 2010

Please note that this output format is defined in PHP date format. For more information, visit the PHP: Date Manual.
decrement   Decreases a returned numerical value by one.

Example:
 %asset_assetid^decrement%
Effect: 100 > 99
divide:<numeral>   Divides a returned numerical value by a set numeral argument.

Example:
 %asset_assetid^divide:2%
Effect: 50 > 25
empty:<replacement>   Displays the set replacement argument when a returned value is empty.

Example:
 %question_answer_46_q1^empty:notanswered%
Effect: not answered will be displayed if the value is empty.
eq:<x:true:false>   Displays 1 (true) or nothing (false), determined by whether a returned numerical value is equal to a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^eq:20%
Effect: If the asset ID is 20, 1 will be displayed. If it is not 20, 0 will be displayed.
 
Example: %asset_assetid^eq:20:YES:NO%
Effect: If the asset ID is 20, YES will be displayed. If it is not 20, NO will be displayed. 
escapehtml   Escapes the HTML of a returned value. See http://www.w3.org/TR/charmod/#sec-Escaping for more information on character escaping.

Example:
 %asset_contents^escapehtml%
Effect: asset&contents > asset&amp;contents
escapequotes   Escapes quotes within a returned value. See http://www.w3.org/TR/charmod/#sec-Escaping for more information on character escaping.

Example:
 %asset_contents^escapequotes%
Effect: “assetcontents” > \”asset contents\”
floor   Rounds a returned numerical value down to the nearest whole integer.
Example: %item_price^floor%
Effect: 13.65 > 13
gt:<x:true:false>    Displays 1 (true) or nothing (false), determined by whether a returned numerical value is greater than a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^gt:10%
Effect: If the asset ID is greater than 10, 1 will be displayed. If it is 10 or less, 0 will be displayed.
 
Example: %asset_assetid^gt:10:YES:NO%
Effect: If the asset ID is greater than 10, YES will be displayed. If it is 10 or less, NO will be displayed. 
gte:<x:true:false>   Displays 1 (true) or nothing (false), determined by whether a returned numerical value is greater than or equal to a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^gte:30%
Effect: If the asset ID is 30 or greater, 1 will be displayed. If it is less than 30, 0 will be displayed.
 
Example: %asset_assetid^gte:30:YES:NO%
Effect: If the asset ID is 30 or greater, YES will be displayed. If it is less than 30, NO will be displayed. 
increment   Increases a returned numerical value by one.

Example:
 %asset_count^increment%
Effect: 10 > 11
lowercase   Displays a returned value in lowercase.

Example:
 %asset_name^lowercase%
Effect: My Site > my site
lt:<x:true:false>   Displays 1 (true) or nothing (false), determined by whether a returned numerical value is less than a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^lt:32%
Effect: If the asset ID is less than 32, 1 will be displayed. If it is 32 or greater, 0 will be displayed.
 
Example: %asset_assetid^lt:32:YES:NO%
Effect: If the asset ID is less than 32, YES will be displayed. If it is 32 or greater, NO will be displayed. 
lte:<x:true:false>   Displays 1 (true) or 0 (false), determined by whether a returned numerical value is less than or equal to a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^lte:65%
Effect: If the asset ID is 65 or less, 1 will be displayed. If it is greater than 65, 0 will be displayed.
 
Example: %asset_assetid^lte:65:YES:NO%
Effect: If the asset ID is 65 or less, YES will be displayed. If it is greater than 65, NO will be displayed. 
maxchars:<numeral>   Limits the maximum character count of a returned value to a set numeral argument.

Example:
 %asset_type^maxchars:4%
Effect: Thesaurus > Thes
maxwords:<numeral>   Limits the maximum word count of a returned value to a set numeral argument. Please note that any content tags and attributes will count towards the word count of the value.

Example:
 %asset_contents^maxwords:100%
Effect: The first 100 words of the asset’s contents will be displayed.
md5   Displays the computer MD5 hash of the returned value.

Example:
 %asset_name^md5%
Effect: Home > 8cf04a9734132302f96da8e113e80ce5
modulo:<numeral>   Calculates n modulo d, where n is a returned numeric value and d is a set numeral argument.

Example:
 %page_number^modulo:3%
Effect: 8 > 2
multiply:<numeral>   Multiplies a returned numerical value by a set numeral argument.

Example:
 %asset_assetid^multiply:10%
Effect: 8 > 80
negate   Negates a returned numerical value.

Example:
 %total_tax^negate%
Effect: 70 > -70
neq:<x:true:false>   Displays 1 (true) or 0 (false), determined by whether a returned numerical value is not equal to a set x argument. This value can be overridden with true and false arguments.

Example:
 %asset_assetid^neq:17%
Effect: If the asset ID is not 17, 1 will be displayed. If it is 17, 0 will be displayed.
 
Example: %asset_assetid^neq:17:YES:NO%
Effect: If the asset ID is not 17, YES will be displayed. If it is 17, NO will be displayed.
nl2br   Inserts a <br /> (HTML line break) before each new line in a returned value.

Example:
 %asset_contents_raw^nl2br%
Effect: asset<br/>
contents.
notempty:<replacement>    Displays the set replacement argument when a returned value is not empty.

Example:
 %question_answer_46_q1^notempty:answered%
Effect: answered will be displayed if the value is not empty
number_format:<precision>    Rounds a returned numerical value to a specific number of decimal places, grouped in thousands, determined by a set precision argument. If no precision argument is set, the returned value will round to the nearest whole integer.

Example:
 %item_price^number_format:2%
Effect: 1234567.789 > 123,456.79
replace:<string:replacestring> Replaces a string in the returned value with the value of a specified replace string. You can use regular expression values on the string that is to be replaced.

Example: 
%asset_name^replace:Matrix:CMS%
Effect: Squiz Matrix > Squiz CMS
round:<precision>    Rounds a returned numerical value to a specific number of decimal places determined by a set precision argument. If no precision argument is set, the returned value will round to the nearest whole integer.

Example:
 %item_price^round:1%
Effect: 1.36 > 1.4
sha1    Displays the computer SHA1 hash of the returned value.

Example:
 %asset_name^sha1%
Effect: Home > 70f8bb9a8a5393ef080507a89e4b98d139000d65
sign:<plus:minus:zero>   Displays the sign (+, – or 0) of a returned numerical value. This returned sign can be overridden with plus, minus and zero arguments.

Example:
 %asset_version^sign%
Effect: 0.2.123 > +
 
Example: %asset_version^sign:up:down:even%
Effect: 0.2.123 > up
squareroot   Displays the square root of a returned numerical value.

Example:
 %item_price^sqareroot%
Effect: 25 > 5
stripdecl   Removes an XML declaration from a returned value.

Example:
 %order_xml^stripdecl%
Effect: Removes XML declaration, eg.
<?xml version=”1.0” encoding=”ISO-8859-1”?>
striphtml   Removes any HTML from a returned value.

Example:
 %asset_contents^striphtml%
Effect: <u>Contents</u> > Contents
subtract:<numeral>   Subtracts a set numeral argument from a returned numerical value.

Example:
 %asset_assetid^subtract:6%
Effect: 111> 105
tag:<tagname>   Wraps a returned value in a set tagname argument XML tag.

Example:
 %asset_contents^tag:body%
Effect: <body>content</body>
tagif:<tagname>   Wraps a returned value in a set tagname argument XML tag. If the returned value is empty, no tags are printed.

Example:
 %asset_name^tagif:title%
Effect: <title>assetname</title>
titleize   Capitalises the first character of each word in a returned value.

Example:
 %asset_name^titleize%
Effect: home page > Home Page
trim   Strips whitespace from the beginning and end of a returned value.

Example:
 %asset_content^trim%
Effect:     content      > content
underscore    Replaces white-space (ie. spaces, tabs, newlines) in a returned value with underscores.

Example:
 %asset_name^underscore%
Effect: Home Page > Home_Page
uppercase   Displays a returned value in uppercase.

Example:
 %asset_name^uppercase%
Effect: training > TRAINING
urldecode   Displays the URL-decoded equivalent of a returned value.

Example:
 %asset_url^urldecode%
Effect: example.com%2Fhome > example.com/home
urlencode   Displays the URL-encoded equivalent of a returned value.

Example:
 %asset_url^urlencode%
Effect: example.com/home > example.com%2Fhome
wordcount    Displays the total words in a returned value.

Example:
 %asset_name^wordcount%
Effect: Home Page of My Site > 5
xpath:<delimiter:xpath>   Runs a set xpath argument query on a returned value and inserts a set delimiter argument between each returned element.
 
Example:
 %asset_contents^xpath:<li><li>://item/title%
Effect: The path lists all titles in the feed, delimited by </li><li>.
xslt:<assetid> Applies the XSLT of a file type asset (specified by asset ID) to the XML content of a returned value.

Example: 
%asset_contents_raw^xslt:190%
Effect: Applies the XSLT of the file asset (#190) to our asset content XML.