Smarty modifiers allow you apply formatting techniques within a template. This saves you from having to apply the formatting within the PHP code, further separating presentation from code and ensuring a more consistent look. A php smarty modifier is most often applied to variables, but can be applied to literal text or functions as well.
To apply a modifier to a variable, follow the variable's name with the pipe (|), then the name of the modifier:
{$var|modifier}
Modifiers can even be chained together:
{$var|modifier1|modifier2}
The modifiers will be applied in order from left to right.
If a modifier accepts additional parameters, follow the modifier name with a colon, then the parameter:
{$var|modifier1:parameter}
Smarty supports the ability to use any PHP function as a modifier. You can even create your own modifiers using plugins.
Changing Case
The "capitalize" modifier will capitalize the first letter in a value. The "lower" modifier will make the entire value lowercase; "upper" will make it all uppercase. The image at right shows the result if you change the template in the sample instructions to
Name: {$name|upper}
Address: {$address|upper}
Concatentation
The "cat" modifier appends a literal string, passed as a parameter, to the value.
{$var|cat:' also print this'}
|