What is fastField?¶
fastField is a plugin which adds new type of tag
[[#...]] . It can be used to display a single field, including template variables and properties, of a different resource for MODX Revolution 2.2+. It also can display the value of superglobal PHP variables $_POST, $_GET and others.
fastField was first released on November 29th, 2012 by argnist.
The plugin can be retrieved through the Package Manager, or downloaded manually from the Repository.
The structure of tag is as follows:
resource_id is an ID of necessary resource, eg. "123", and field is a resource field, eg. "pagetitle". For Template Variables the field should be prepended by "tv.". For Resource Properties it should be prepended by "properties." or "property.".
For usage with global arrays you must replace
resource_id by array name, eg. "post" and field by the name of a variable.
Return the pagetitle from the resource with id 123:
Return the introtext of a parent of a current resource and display description for empty one:
Or, more efficiently (see this MODX blog article):
Return the content of the resources in
rowTpl chunk while Wayfinder usage:
Return TV image from the resource with id 10:
articlesPerPage from the resource with id 1 of custom resource type Articles
Return the value of $_POST['myVar']:
Supported global arrays:
$_SESSION. The type of array after # is case-insensitive. The name of array element is case-sensitive. You should use uncached tag, eg.
[[!#get.name]], for cached resources.
CAUTION: It is dangerous to use raw global variables on the page. For example, use
:stripTags output filter to prevent XSS-attacks (eg.
How it works¶
modParser class for parsing default tags. This plugin adds class
fastFieldParser that extends modParser. So, if
modParser is modified in new version of MODX, the behaviour of plugin will be unpredictable.