TMPL Reference
The TMPL file is an XML file that typically includes XML, XHTML, OU Campus tagging, and the Echo Variable and Set Variable elements. Predefined variables can be used in .tmpl files to echo, or print, values relating to, for example, directory names, includes, site name, and user-provided input. This allows the TCF to pass a value and the TMPL to use it in their combined effort to manufacture a PCF. These predefined system variables are particularly handy to dynamically create a path to the root of the site or any other area of the site. They can be useful for utilizing recursive includes for, say, a breadcrumb trail.
At a general level, a TMPL is simply a PCF with echo variables in place of hard-coded content. This page will cover echo variables and other elements unique to a TMPL file (as opposed to elements such as OU Campus and Page Properties tags that are present in both TMPLs and PCFs). For more information about OU Campus tags found in PCFs and TMPLs, please visit the following pages:
The major headings on this page are:
- Echo Variable Tag Overview
- More about Encoding and Output
- Variables
- Set Variable Tag
- More about Defining Variables
Echo Variable Tag Overview
The value of a variable gets echoed or printed into a new file being created. Note that there is not a space between the first comment tag and the percent sign.
Syntax
<!--%echo var="current" -->
Example
<meta name="keywords" content="<!--%echo var="current" -->">
Attributes
More about Encoding and Output
When creating user-input elements in the TCF or page parameters, the attribute "type" is used within the <variable> node to specify the type of element. Some types can include options. It's the value of the option specified by the user that is used to determine something about the page content or page configuration. Types that can include options are the checkbox, select (pick list), and radio (radio buttons).
These variable types (checkbox, select, radio) can maintain the form field type (rather than getting converted to text) if <option> tagging is preserved in the PCF. To do this, specify the output method as xml (output="xml") in the TCF variable definition. The corresponding node in the TMPL must include in its echo var statement the attribute to turn off output encoding to avoid changing the <option> nodes into plain text. To do this, use encoding="none" in the appropriate TMPL echo statement.
This outputs all of the options instead of just the value from a TCF variable to a TMPL.
The combination of output="xml" and encoding="none" will output all of the option nodes where the echo statement is within a TMPL file.
Variable Reference
Current Date Variable
The current date variable outputs the current date and time at the time of page creation.
Syntax
<!--%echo var="currentDate" -->
Example Usage
<parameter name="datetime" prompt="Date created" alt="Date created.">
<!--%echo var="currentDate" --></parameter>
Example Output
<parameter name="datetime" prompt="Date created" alt="Date created.">Wednesday, November 27, 2013 8:59:12 AM PST</parameter>
Common Tree Variable
Prints the name of the current directory.
Syntax
<!--%echo var="commontree" -->
Example
<a href="/<!--%echo var="commontree" -->/index.html">
Current Variable
Prints a path to the current directory from the root of the site.
Syntax
<!--%echo var="current" -->
Example
<meta name="keywords" content="<!--%echo var="current" -->">
Directory Variable
Prints a path to the current directory from the root of the site, followed by a slash.
Syntax
<!--%echo var="directory/" -->
Example
<a href="/<!--%echo var="directory/" -->index.html">
Includes Variable
Prints the path from the site root to the parent directory and adds a trailing "includes" directory (i.e., "currentdir/includes").
Syntax
<!--%echo var="includes" -->
Example
<a href="<!--%echo var="includes" -->/leftnav.html">
Parent Variable
Prints the path from the site root to the directory that contains the current directory (i.e., one directory "above" the current location).
Syntax
<!--%echo var="parent" -->
Example
<a href="/<!--%echo var="parent" -->index.html">
Relative Root Variable
Prints the relative path from the current directory to the staging root (i.e., "../../currentdir/"). This variable is particularly useful when used in PCFs or utilized in XSL transformations.
Syntax
<!--%echo var="relativeRoot/" -->
Example
<config><!--%echo var="relativeRoot/" -->resources/config/standard.xml</config>
Site Name Variable
Prints the name of the current site (determined by an administrator).
Syntax
<!--%echo var="sitename" -->
Example
This page is part of the <!--%echo var="sitename" --> site.
Set Variable Tag
Defines a new variable within a TMPL.
Syntax
<!--%set -->
Example
<meta name="keywords" content="<!--%set var="metakey" -->">
Attributes
More about Defining Variables
Group Tag
To set editing access for a page created by a new page template:
<!-- com.omniupdate.meta group="Everyone" -->
Note: "Everyone" is a standard group available in all accounts. Any other account-specific group name may also be used.
Filename Tag
To set a default file name for new pages created by templates:
<!-- com.omniupdate.meta filename="index" -->
Extension Tag
To set a default extension to a file name for new pages created by templates:
<!-- com.omniupdate.meta group="Secondary Nav" filename="rightnavlinks" extension="inc" -->
Echoing Variables
User-Defined Echo Tags
To echo any user-defined variable as defined above, simply use the following format:
<title><!--%echo var="title" --></title>
Meta Echo Tags
To echo any of the default meta fields from a non-TCF defined new page form, use the following format:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="<!--%echo var="metakey" -->">
<meta name="description" content="<!--%echo var="metadesc"-->">
Title Echo Tag
Tthe following format can be used to include the page title within the body of the page:
<!--%echo var="title" -->
Other System-Defined Echo Tags
How to write a path within the same directory:
1. First, declare a variable to use as follows:
<!--%set var="myvarname" directory="current" file="_section-path.html"-->
2. Second, use the new variable as follows:
<!-- com.omniupdate.div label="breadcrumb-preview" group="z-nav-section-name" path="<!--%echo var="myvarname" -->" button="125" position="bottom" -->
To write a path up one directory:
1. First, declare a variable to use as follows:
<!--%set var="myvarname" directory="parent" file="_section-path.html"-->
2. Second, use the new variable as follows:
<!-- com.omniupdate.div label="breadcrumb-preview" group="z-nav-section-name" path="<!--%echo var="myvarname" -->" button="125" position="bottom" -->