Introducing template variables
Template variables give life to otherwise static layouts. They allow templates to have dynamic content. You have already seen an example of a resource-specific template variable when you used [*#content*]
in the template that you created in the last section. Template variables are entities that may have different values in different pages for different users at different times. They can be embedded in a template or in a resource's content, in order to display the value that they store. The value of a template variable can generally be shown in a template by enclosing the name of the template variable within [*
and *]
, like [*template variable name*]
. This is a good time to check out the code of the templates that came with the sample site when MODx was installed, in order to consolidate your understanding of what is happening. Template variables are created and assigned to documents, as we will see in the next section.
Besides the template variables that are...