Modifiers
Below is a list of options that can be used across all Smart Tags.
--layout
By default, all Smart Tags return a plain text value. For instance, the {device} Smart Tag will output “desktop” on desktop users. What if you want to wrap the value with a div and make it bold?
To do so, write:
{device --layout=<div><strong>%value%</strong></div>}
The layout option expects a text or HTML with the %value% variable representing the Smart Tag value.
You may think that you don’t need this option as you can get the same result by just inserting the HTML and shortcode directly in the page like:
<div><strong>{device}</strong></div>
You have a point that will work, but the main drawback of this method is that the outer HTML will be outputted in the page even if the Smart Tag returns an empty string. If the Smart Tag cannot determine the device type, you will be left with orphaned HTML tags. This may result in an undesired behavior. The layout option solves this issue by outputting the shortcode value only if it is not empty.
--prepareContent
If a Smart Tag returns a value that contains other shortcodes, those shortcodes will likely remain unparsed. To work around this, pass the --prepareContent option to enable Joomla Content plugin parsing.
{SmartTag --prepareContent=true}
--shortNumber
Converts a number into a short version, eg, 1000 -> 1k and 10000 =-> 10K
{SmartTag --shortNumber=true}
--filter
Use this modifier to filter the output of a Smart Tag based on certain rules and increase security. The available filter options are:
- INT: Returns the first integer found in the value. For example, if the value is "abc123def456," then the return value from applying this filter would be 123 (as an integer).
- UINT: Returns an unsigned int. For example, if the value is -2, this filter will discard the minus sign, and you will get the value 2.
- FLOAT: Returns the first float found.
- BOOLEAN: A boolean value
- WORD: Filters out any characters which aren't letters or an underscore
- ALNUM: Filters out any characters which aren't letters or numbers
- CMD: Filters out any characters that aren't letters, numbers, underscore, dot or dash, and removes any leading dots from the result
- BASE64: Filters out any characters that aren't letters, numbers, forward slash, plus, or equals. base64 can be used to encode a URL as a string of text.
- STRING: Converts any HTML entities to their corresponding characters.
- HTML: Removes HTML tags, but without previously converting HTML entities.
- ARRAY: Performs no filtering, just tries to convert the parameter to an array.
- PATH: Converts the input into a string and validates it as a file path (e.g. path/to/file.png or path/to/dir), checking it first against the pattern for a linux path, and then against the pattern for a Windows path. Note: Does NOT accept absolute paths, or paths ending in a trailing slash. If it fails to match against a valid path then the empty string is returned.
- TRIM: A string trimmed from normal, non-breaking, and multibyte spaces
- USERNAME: Filters out characters not permitted in a Joomla username
{SmartTag --filter=FILTER}
You can create custom filters using regular expressions if the available filters don’t meet your requirements. Prefix your regular expression with “re:” in the filter property.
For example, the following expression removes all whitespace from the output:
{SmartTag --filter=re:\s+}