String modifiers
cat
Appends a value after the tag.
[[+numbooks:cat=`books`]]lcase, lowercase, strtolower
Converts all letters to lowercase.
[[+title:lcase]]ucase, uppercase, strtoupper
Converts all letters to uppercase.
[[+headline:ucase]]ucwords
Capitalizes the first letter of each word.
[[+title:ucwords]]ucfirst
Capitalizes the first letter of the string.
[[+name:ucfirst]]htmlent, htmlentities
Converts all characters to their HTML entities.
[[+email:htmlent]]esc, escape
Safely escapes characters using regular expressions and str_replace(). Also escapes MODX tags.
[[+email:escape]]strip
Replaces all line breaks, tabs and any amount of spaces with a single space.
[[+textdocument:strip]]stripString
Removes the specified substring from the string.
[[+name:stripString=`Mr.`]]replace
Replaces substrings.
[[+pagetitle:replace=`Mr.==Mrs.`]]striptags, stripTags, notags, strip_tags
Strips all tags (allowed tags can be specified). Do not use for security.
[[+code:strip_tags]]len, length, strlen
Outputs the length of the string.
[[+longstring:strlen]]reverse, strrev
Reverses the string character by character.
[[+mirrortext:reverse]]wordwrap
Inserts a line break after every n-th character (words are not split).
[[+bodytext:wordwrap=`80`]]wordwrapcut
Inserts a line break after every n-th character, even if that character is inside a word.
[[+bodytext:wordwrapcut=`80`]]limit
Outputs a given number of characters from the start of the string.
- Default:
100
[[+description:limit=`50`]]ellipsis
Adds an ellipsis and truncates the string if it is longer than the specified number of characters.
- Default:
100
[[+description:ellipsis=`50`]]tag
Escaping. Displays the element as-is, without :tag. For use in documentation.
[[+showThis:tag]]add, increment, incr
Adds the specified number.
- Default:
+1
[[+downloads:incr]] [[+blackjack:add=`21`]]subtract, decrement, decr
Subtracts the specified number.
- Default:
-1
[[+countdown:decr]] [[+moneys:subtract=`100`]]multiply, mpy
Multiplies by the specified number.
- Default:
*2
[[+trifecta:mpy=`3`]]divide,div
Divides by the specified number.
- Default:
/2
[[+rating:div=`4`]]modulus,mod
Returns the modulus.
- Default:
%2 - Returns:
0 | 1
[[+number:mod]]ifempty,default,empty, isempty
Returns the modifier value if the tag value is empty.
[[+name:default=`anonymous`]]notempty, !empty, ifnotempty, isnotempty
Returns the modifier value if the tag value is not empty.
[[+name:notempty=`Hello [[+name]]!`]]nl2br
Replaces newline characters \n with the HTML br tag.
[[+textfile:nl2br]]date
Formats a timestamp as text according to the specified date format.
[[+birthyear:date=`%Y`]]strtotime
Converts a date string to a UNIX timestamp.
[[+thetime:strtotime]]fuzzydate
Takes a timestamp and returns a date like "Today at 4:20 PM".
[[+createdon:fuzzydate]]ago
Returns the number of seconds, minutes, weeks or months since the date in the tag.
[[+createdon:ago]]md5
Creates an MD5 hash of the value.
[[+password:md5]]cdata
Wraps the output in CDATA tags.
[[+content:cdata]]userinfo
Returns the requested value from the user profile. The user ID must be specified.
[[!+modx.user.id:userinfo=`username`]]See the UserInfo modifier for details.
isloggedin
Returns 1 if the user is logged in to the current context.
[[!+modx.user.id:isloggedin:is=`1`:then=`Yes`:else=`No`]]isnotloggedin
Returns 1 if the user is not logged in to the current context.
[[!+modx.user.id:isnotloggedin:is=`1`:then=`No`:else=`Yes`]]urlencode
Encodes the value for use in a URL (PHP urlencode()).
[[+mystring:urlencode]]urldecode
Decodes a URL-encoded value (PHP urldecode()).
[[+myparam:urldecode]]Внимание
User-related modifiers must be called uncached so each user sees their own data.