Common Template Tags
This page lists the most commonly used MODx Revolution tags as an aid to anyone converting HTML/CSS layouts into MODx Templates. These are frequently referred to as "tags" or "placeholders" (and sometimes "template variables"), so we mention those terms here as an aid to searching, although technically speaking they are not placeholders or template variables: they are MODx tags. Yes, it can be confusing for the newcomer, so just remember that there are different flavors of these tags, each with its own purpose and name. Placeholders are set in code and are displayed with placeholder tags. Template Variables are extra resource content fields created by the user; they can be thought of as custom fields. Neither placeholders, not template variables are pre-set by the MODx core.
Default Resource Content Field Tags
In MODx Revolution, each page will always have the following content fields that you can use when constructing your templates. Except for the Resource ID and the parent field, they are all supplied by the user when editing the resource and may be empty if the user did not fill them in:
|[[*id]]||the Resource ID of the page (set by MODx when the page is created.||Often used in conjunction with the link syntax, e.g.
|[[*pagetitle]]||the Title of the page.||
|[[*longtitle]]||the Long Title of the page||
|[[*alias]]||the page alias.||Used to construct the URL of the page|
|[[*description]]||the page Description||
|[[*introtext]]||the Introductory Text field (a.k.a. the summary).||Often used by Snippets to summarize posts, e.g. Ditto
|[[*parent]]||the ID of the parent page (if any). Set by MODx when the page is created. Can be altered by the user.||Often used in conjunction with the link syntax, e.g.
|[[*menutitle]]||the Title used when the page appears in menus.||Most frequently used by Snippets such as Wayfinder when dynamically constructing menus|
|[[*content]]||the content of the page.||
Other Common Tags
These tags represent system settings, which are editable under the System menu -> System Settings.
|[[++site_url]]||Contains the URL for your site, e.g. http://www.yoursite.com/||With many CMS's that rely on Apache rewrites, it's common practice to include a base tag in your HTML head:
|[[++site_name]]||Name of the site||
|[[++site_start]]||Contains the ID of the page designated as your "home" page.||Often used in conjunction with the link syntax, e.g.
|[[$chunk]]||This references a chunk by name. Chunks are any bit of reusable content.||Common chunks might be for header or footer|
|[[~link]]||Use this syntax to build links to pages by referencing their unique id (visible in parentheses next to the page's name in the resource tree). These links will not break if pages are moved or renamed. You can change the generated scheme of the link by passing the &scheme parameter (see link_tag_scheme)||
|[[%translated_message]]||Use lexicon tags to localize messages.||[[!%setting_emailsender? &topic=
As you increase your understanding of how MODx templates work, you'll want to have at your disposal the complete list of available content fields. Here is the complete list of all tags, gleaned from this blog post.
|Tag||Data Type||Description||Example Usage|
|[[*alias]]||text||Alias||Normally, you will use the id to generate the URL, e.g.
|[[*class_key]]||int||Class Key of the Resource, e.g. modDocument|
|[[*createdon]]||date||Created On date, e.g. 2011-04-14 20:40:50, often used in conjunction with the strtotime output filter||
|[[*createdby]]||int||Created By User ID Number|
|[[*deletedby]]||int||Deleted By User ID Number|
|[[*deletedon]]||date||Date of Deletions||
|[[*editedon]]||date||Edited On date, e.g. 2011-04-18 09:06:08||
|[[*editedby]]||int||Edited By User ID number|
|[[*hidemenu]]||int 0/1||Hide From Menus; this attribute is read by many Snippets, e.g. WayFinder|
|[[*id]]||int||Resource ID||Used frequently to generate links to this page.|
|[[*link_attributes]]||text||Link attributes; these are inserted automatically when you use the [[~123]] syntax|
|[[*pub_date]]||date ---Publish Date|
|[[*publishedby]]||int||Published By User ID Number|
|[[*richtext]]||int 0/1||Rich Text|
|[[*template]]||int||Template ID number|
|[[*unpub_date]]||date – Unpublish Date||
|[[*uri_override]]||int 0/1||Freeze URI|
Just to clarify on pub_date – it's only set when the user sets a future date for publication in the Publish On field. And when the doc is actually published, it's zeroed out. The publishedon field always contains the most recent date that the resource changed form unpublished to published (or the date a new doc was saved with Publish checked).
- Date Formats : shows how to format date fields.