Jump to content

Guides

Template plugins

It's often useful to transform raw values in some way, and this is achieved in IPS4 with template plugins. Template plugins take a value, and optionally some arguments, and output some transformed value.

The syntax for template tags is:

{pluginkey="<value>" argument="..."}

The value can be a normal string, or it could be a variable coming from elsewhere.

Template plugins can always be used in templates, but some can also be used in CSS files. Those that can are identified below.

 

Available plugins

{advertisement="$location"}
The HTML for the specified ad location

Parameters
$location - A valid advertisement location

 

{datetime="$timestamp" dateonly="[boolean]" norelative="[boolean]" lowercase="[boolean]" short="[boolean]"}
Shows a time formatted according to the user's locale

Parameters
$timestamp - A timestamp to transform into a date
dateonly - Show only the date (with no time)
norelative - By default, relative times will be used (e.g. 8 hours ago). To always show an absolute date/time, set this to true.
lowercase - By default, date strings will be capitalized where necessary (e.g. Yesterday, 8:32pm). Setting this to true ensures it is lowercase, for use in a sentence.
short - Uses a very short date format (ideal for mobile devices)

 

{expression="$expression" raw="[boolean]"}
Allows the result of arbitrary PHP expressions to be inserted into templates. The result of the expression is output.

Can be used in CSS files.

Parameters
$expression - A valid PHP expression that produces output of some kind
raw - By default, the result of the expression is HTML-escaped. Setting this parameter to true outputs the raw result. Be careful! This can be a security risk.

 

{file="$file" extension="[string]"}
Outputs the URL to a file stored by IPS4's file handling classes.

Can be used in CSS files.

Parameters
$file - Either an instance of the \IPS\File class, or a string representing the stored URL to the file
extension - The file storage extension used to originally store the file, e.g. calendar_Events. If none is specified, core_Attachment is assumed.

 

{filesize="$sizeInBytes" decimal="[boolean]"}
Formats the specified filesize and outputs an appropriate human-readable form.

Parameters
$sizeInBytes - An integer representing a file size, in bytes, to be formatted
decimal - Whether the filesize should be treated as a KB (i.e. 1kb = 1024 bytes) or 1 = 1000. All values are always rounded to one decimal place.

 

{insert="$filename"}
Includes a PHP script file

Parameters
$filename - The filename of the PHP file to include. The output of the file is buffered and output.

 

{lang="$languageKey" sprintf="[string]" htmlsprintf="[string]" pluralize="[string]" wordbreak="[boolean]" ucfirst="[boolean]"}
Inserts a phrase from the language system in the user's chosen language.

Paramaters
$languageKey - The key of the language phrase to insert
sprintf - Comma-separated list of values to replace in the language string. These values are HTML-escaped.
htmlsprintf - Comma-separated list of values to replace in the language string. These values are not escaped. Be careful!
pluralize - Comma-separated list of values to pass into any pluralize statements in the language string.
wordbreak - If true, adds <wbr> tags to the returned string to help prevent strings that break the page width.
ucfirst - Determines whether the first character of the string should be made uppercase.

 

{member="$propertyToDisplay" id="[integer]" group="[boolean]" raw="[boolean]"}
Outputs the property or result of a method called on the member object.

Parameters
$propertyToDisplay - One of the properties or methods available on the member object. For example: link() or name.
id - Member ID to load and display. If not specified, the current member is used.
group - If true, this tag works on the member's group instead (and so the $propertyToDisplay should be one of the group properties or methods instead)
raw - By default, the returned output is HTML escaped. Setting this to true means the output won't be escaped. Be careful!

 

{number="$number"}
Formats a number according to the user's locale (e.g. with commas or periods)

Parameters
$number - Number to format

 

{prefix="$CSSPropertyName" value="[string]"}
Shortcut tag which automatically prefixes the provided CSS property with vendor prefixes.

Can be used in CSS files.

Parameters
$CSSPropertyName - The property name to prefix. The supported properties are: transition, transform, animation, animation-name, animation-duration, animation-fill-mode, animation-timing-function, user-select, box-sizing, background-size.
value - the value of the CSS property.

 

{request="$requestParameter" raw="[boolean]"}
Inserts the value of a request parameter.

Paramaters
$requestParameter - The parameter from the request object to be inserted.
raw - By default, the returned value is HTML-escaped. If this parameter is true, the output won't be HTML-escaped. Be careful!

 

{resource="$path" app="[string]" location="[string]" noprotocol="[boolean]"}
Returns the absolute URL to the specified resource.

Can be used in CSS files.

Parameters
$path - Relative path to the required resource (path is relative to the current theme's /resource directory)
app - The app to which the resource belongs.
location - The location (front/admin/global)
noprotocol - Whether to make the resulting URL protocol-less (i.e. do not include http:// or https:// at the beginning, which can be useful for resources which are not allowed to be loaded over http on an https connection)

 

{setting="$settingKey" escape="[boolean]"}
Inserts the value of a system setting.

Can be used in CSS files.

Parameters
$settingKey - Key of the system setting to insert.
escape - By default, the raw value is output. If you need the value to be HTML-escaped, pass true for this parameter.

 

 


  Report Guide


×