Part Two - The Basics

Output Modifiers - control MODX tag output

Output Modifiers

Output Modifiers are a quick way to change the output of most MODX tags, particularly resource field and TV output and placeholders.There is a large selection of conditional and string modifiers, including the very useful "userinfo" for getting user information from the MODX-provided current user placeholder, or any other source of a user ID.

I can't believe it's butter!
</p>

Even if one of the provided modifiers doesn't do what you need, creating custom Output Modifiers is not a difficult process. A custom Output Modifier is just a snippet, with a set of variables for the values to work with automatically available. These variables include an $input variable for the original value of the MODX tag, and an $options variable for any additional option that may have been included in the tag. Just use those variables in your snippet process, and return the results like any other snippet.

Don't forget about the "MODX tags as the result" method of minimizing the footprint of processing output modifiers, as explained by Jason Coward in his famous "mosquitoes" MODX blog post. Sometimes if the conditional output will include large amounts of data, which gets processed and stored whether it gets used or not, it's better to use a wrapping chunk and this "mosquito" method to output the chunk tag if it's used. The chunk tag will get processed in the next pass through the parser.

The official documentation can be found in the RTFM.


Susan Ottwell
May 2016