MODx Tags

Introduction

The core of any templating or content management system is the way it creates blocks of different kinds to separate the presentation of content from the creation of the content. MODx uses simple tags to create content that an editor can insert into a document without having to worry about how that content is created.

MODx Tags give you a simple, powerful way to include more variable content into your web pages.

Tags are replaced with the content they output. Here are a few examples:

Snippets

To execute snippets, insert the snippet's name in the snippet tag where you want the snippet's output to appear in your document or template. For example, [[MySnippet]]
Snippets are simply raw PHP code whose output is displayed in the location where the snippet tag is placed. For more information see Adding Snippets, as well as Document Caching, in the Designer's Guide.

Settings

Settings tags insert the specified site-wide system setting. For example, [(site_name)] will insert the name of your site. This is often used in page headers.

A list of settings can be found in the MODx database in the table "(PREFIX)system_settings" where (PREFIX) is your table prefix.

Following is a complete list of the settings, with a line through settings that are no longer used as in [(config_setting_name)]:

Template Variables

TVs are a powerful method of inserting blocks of content specific to the page being displayed. They take two basic forms:

1. TVs can display basic document attributes, which are found in the MODx database in the table (PREFIX)site_content table in the MODx database where (PREFIX) is your table prefix.

These are the most commonly used document attributes:

2. TVs can be programmed to generate widgetssuch as tickers, sliders, marquees, and data grids displaying the results of database queries. They can generate Rich Text Editors for user comments or forum entries.

With TVs, you don't need to be concerned about how these things are created, all you need to do is insert the TV tag where you want the widget to appear in your page.

Many TVs can even be customized for a specific document at the same time you are editing the document. They can provide lists or options you can select to apply to the document you are editing.

For more information see Template Variables in the documentation.

Timing

There are several timing tags in MODx:

For example, for this page, MySQL queries took 0.0000 seconds for 0 queries(s), document parsing took 0.3043 seconds, for a total time of 0.3043 seconds, and retrieved from cache.

Links

To insert a link to another document within your MODx site, simply put the id number of the document in the link tag. For example, [123] will create a link to the document with ID 123.

Once MODx starts parsing the document, it will automatically select the best URL to create for this document, where 'alias' has precedence over 'friendly urls', which have precendence over 'index.php?id=123' style links. You can combine this with other tags, so [(site_start)] will output the URL for your site start page.

Chunks

Chunks contain plain text, usually HTML code, which will not be parsed by MODx, but simply inserted into the page.

They are very convenient for holding general content, such as for a page footer, that is to appear on all pages of a site. For example, if your footer contains your telephone number, and your number changes, you only have to make the change in the chunk, and not on every page on the site!

By using combinations of snippets, TVs and chunks, you can make your site pretty flexible! For example, you could have a snippet which outputs the tags for a chunk, which can contain tags for other snippets.

Chunks are also used to contain lists of options for TVs, and the same chunk can be included into any number of TVs to provide the same options (@CHUNK binding).

For more information about Chunks, see Chunks in the documentation.

Placeholders

The most common use for placeholders is to position the output of a snippet. An example of this can be seen in the NewsListing snippet's default template:

<div class="nl_summaryPost">

<h3><a href="[+id+]">+title+</a></h3>

<div>+summary+</div>

<p>+link+</p>

<div style="text-align:right;">by <strong>+author+</strong> on +date+</div>

</div>

A placeholder can be used anywhere in any HTML code where you wish that particular piece of a snippet's output to appear. A good example of that is the Personalize snippet. It merely returns the user's name, and can be used either as a normal snippet or as a placeholder. You can put the snippet once in your template or document, then put the placeholder in as many places as you like, such as in a greeting at the top of the page, and in the "logout" section of the weblogin snippet's template.


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

Other Features

Add Content