Home > The Template System > Template Placeholders

Table of Contents

DotAdmin User Guide

Template Placeholders

Placeholders are the simplest instructions you can provide for the template system. As the name suggests, they act as markers which will be replaced by content when a page using this template is presented to your visitors. A placeholder consists of a simple name which references the content you want to display, enclosed within curly braces.

<h1>{title}</h1>

The example above would ask the template system to retrieve the title of the current page from the content database, and display it as a heading 1 in the resulting page.

The placeholders available for use in a template are determined by the type of template you are creating. For example: A template used to display a product will not use all the same placeholders as a template which displays a page. For a list of all the placeholders available for a particular type of template, please see the page dedicated to that template type in this section.

Placeholder Includes

Placeholders can also be used to collect data from elsewhere in the system and display it in the current page—data which isn't directly related to the page to be displayed. These placeholders are known as “Includes”.

Includes are contained within curly braces, like all other placeholders. They usually consist of a “type”, describing the kind of content you are including, followed by a name which identifies the content you wish to include.

Below are examples of how to write each type of include, with an explanation of what they do.

{fragment [template_id]}

Fragment Includes tell the system to insert a Fragment template into the current template. For example: {fragment header} would ask the system to find a Fragment template called “header”, and include it in the current template.

Fragments can be included in any type of template.

Note: Fragments are commonly used for frequently-repeated chunks of HTML. For example: If you create a fragment template containing all the <head></head> mark-up for a web page, you could then include it in all your page templates just by including {fragment head}.

{nav [nav_id]}

The Nav Include tells the system to generate a menu of links and include it in the page. For example: {nav mainmenu} would build the “mainmenu” Nav and include the results in the current template.

Navs can be included in any type of template.

Note: Further information regarding automated Navs is available in the Nav System section. For template-specific information, see the Nav Templates section.

{process [process_id]}

Process Includes are used to run programs and display the results in the current template. For example: {process cart} would retrieve the current user's shopping cart. The shopping cart itself has its own template, and the results of the cart data combined with this template would make up the output from this placeholder.

Processes can be included in any type of template.

Placeholder Qualifiers

By default, when the system replaces a placeholder with data, the data is first made web-safe by converting characters such as quotation marks and ampersands into HTML entities, and converting newlines to <br> tags. The only exception to this rule is the {content} placeholder. This placeholder is assumed to already contain HTML which should be preserved, and so it is not escaped by the system.

There may be times where you do not want data to be formatted in this way. In these cases, you can use a Placeholder Qualifier to tell the system what to do with the data you are going to display.

Qualifiers should be contained within the placeholder's curly braces, before the placeholder name. This follows the exact same format as for Placeholder Includes, described in the section above. For example:

{literal title}

The above code would display the title "literally", and would not perform any formatting of the page title. The following is a list of all placeholder qualifiers, and typical uses:

{text [name]}

The text qualifier is the default setting for all placeholders other than {content}. All characters unsuitable for display on a web page are converted into web-friendly versions, including newlines converted to <br> tags.

{literal [name]}

As mentioned above, a literal placeholder will not format the output at all. This is most useful for outputting data containing HTML which you wish to preserve.

Note: This is the default setting for the {content} placeholder, because this placeholder usually refers to data which contains HTML.

{addslashes [name]}

An addslashes qualifier tells the system to escape single and double quotation marks with a backslash character. This is useful for outputting values which will be used in Javascript.

{escaped [name]}

With an escaped placeholder, illegal characters are converted to HTML entities, but newlines are preserved. This is useful when outputting to <textarea> form fields, <pre> tags, or any other mark-up which displays newlines.

{url [name]}

The url qualifier, as the name suggests, encodes any illegal characters to form a valid URL.

Zone Detail

The ZONE block can be used to display details about a specific zone, eg:

<!-- ZONE home --><h1>{title}</h1><!-- /ZONE home -->

The above example would display the title of the home zone inside h1 tags.

This can also be used to dynamically obtain details about a zone specified within the document, eg:

<!-- ZONE {zone} --><h1>{title}</h1><!-- /ZONE {zone} -->

The above example would display the title of the document's current zone, as specified by the {zone} placeholder.