Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Learning the template language

A study plan for Exponential's template language (eZ TPL) - what it is, a first template to type, the five constructs to learn first, a reading order through the template language and designer pages, practice drills on…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/students/learning-the-template-language.md

On this page

Learning the template language

Exponential renders every page, mail and PDF with its own template language, known as eZ TPL: brace tags like Smarty's, with operators and functions for content objects, a fetch API to read data, an override system to choose templates, and a compiler that turns templates into PHP (The template language). Designers and developers both need it. This page gives you a study plan.

Contents

  1. The five constructs to learn first
  2. Your first template
  3. A reading order
  4. Drills
  5. Mistakes learners make
  6. If you know Smarty

The five constructs to learn first

ConstructExampleMeaning
Output with escaping{$node.name|wash}Print a value; wash escapes HTML. Use it on anything a user typed
Variables{def $items = ...}, {set $items = ...}, {undef $items}Declare once, change later, free
Datafetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'limit', 5 ) )Read content; hash builds named values
Loops and conditions{foreach $items as $child}...{/foreach}, {if $node.depth|gt( 2 )}...{/if}Operators are written as pipes: gt, lt, eq, and, or, not
Showing content{attribute_view_gui attribute=$node.data_map.title}, {node_view_gui content_node=$child view='line'}Let each attribute and node use its own template

Source: Templates and design, part 6. Comments are written {* ... *}. Links use ezurl, written without quotes in an attribute: <a href={$child.url_alias|ezurl}>.

Your first template

The templates guide gives a small template to try in an override (it lists the children of the current item's parent, ten at most):

<h1>{$node.name|wash}</h1>
{def $siblings = fetch( 'content', 'list', hash( 'parent_node_id', $node.parent_node_id, 'limit', 10 ) )}
<ul>
{foreach $siblings as $sibling}
    <li><a href={$sibling.url_alias|ezurl}>{$sibling.name|wash}</a></li>
{/foreach}
</ul>
{undef $siblings}

Expected: the heading followed by a list of links. Put it in the override of project 3, then explain each line in your study journal.

A reading order

Start task-oriented, then go deep:

  1. Templates overview and TPL syntax basics, the gentle introduction.
  2. Templates and design, parts 1 to 6: how a template is found, overrides, syntax checks.
  3. What the template language is.
  4. Values and literals and Variables in depth.
  5. Control structures reference.
  6. The object model in templates and Data map and content.
  7. Errors and debugging.
  8. Template resources and overrides and Template caches.
  9. The operator reference as you need it: Template operators.

The trainers' Developers course has a whole module on the language, module 2, with exercises and quizzes.

Drills

Short exercises, each on your study site, in an override you can remove afterwards:

  1. Print the name and the node number of the current item.
  2. List the first five children of the item with links. Then show "No items" when there are none.
  3. Show the title attribute with attribute_view_gui, then print $node.data_map.title.content and compare.
  4. Use {delimiter} to put commas between names in a loop.
  5. Put a deliberate error in a template (an unknown operator), check it with php bin/php/eztemplatecheck.php, then read what the engine logs (Errors and debugging).

Mistakes learners make

MistakeResultFix
Forgetting washText with < or quotes can break the page or open a security hole|wash on every value from content or visitors
{def} the same variable twiceA warning{def} once, {set} afterwards
Editing design/standard/templates/Lost at the next upgradeAn override in your own design
Expecting arithmetic like $a + 1Does not workOperators such as sum; see the differences from Smarty
A new template path without clearing cachesThe old template is usedClear the override and template caches once

If you know Smarty

Read Smarty and the template language side by side and the differences in depth: no infix arithmetic or comparison, no PHP in templates, no automatic escaping, and overrides instead of inheritance.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x