Templates
This chapter explains how Exponential 6 turns content into pages: the template files, the template language, the designs a siteaccess uses and the order in which they are searched, the override rules that pick a template for a class, a node or a section, the pagelayout, caching inside templates, the three template engines, and the tools for editing and debugging templates. It is written for site builders and template developers and describes Exponential 6.0.15.
Read in this order
- How templates work: what a template is, how a request becomes a page, node templates and system templates.
- The template language: syntax, variables, control structures, functions and operators.
- Designs and design order: SiteDesign, AdditionalSiteDesignList, designs in extensions, and where a template is looked for.
- The template override system: override rules in override.ini, the match conditions and their order.
- The pagelayout: the main template, its variables and the page head.
- Basic template tasks: includes, links and design files, view parameters.
- Information extraction: fetch functions, and printing node and object data.
- Template caching and cache-block: the compiled templates, the view cache and cache blocks.
- Template security and wash: escaping output.
- Template engines: .tpl, Smarty and Twig: the three engines of 6.0.15 and the converters between them.
- The Template Editor: overrides and template files from the Design tab of the administration interface.
- Debugging templates: the Exp Debug bar, the list of used templates, template path comments and the syntax check.
Reference
The reference pages are generated from the kernel, so they list exactly what your installation has. Use them instead of copying parameter lists into your notes:
- Template operators: every registered operator, its parameters and an example.
- Template functions: every function such as include, def, foreach and cache-block.
- Fetch functions: every fetch function of every module, with its parameters.
- Template override conditions: the match keys each view offers.
- The template language manual: the language in depth, from lexical structure to the compiler.
- Templates and design: a fifteen-minute walkthrough that changes a page with an override.
History
The template language comes from eZ Publish, the system Exponential continues; its repository history starts in 2002, and def, if and foreach replaced the older let and section in version 3.6 (2005). The older style still runs: the standard page_head.tpl of 6.0.15 uses let and section to this day. The full story is in the history of the template language. What Exponential added is listed on the pages above, notably the Smarty and Twig engines, override priorities, the Exp Debug bar and template path comments. The comments readers left on the earlier pages are kept below the pages they were written on, marked as historical.
In this section
- How templates work How Exponential 6 turns a request into a page: templates, the pagelayout and $module_result, node templates and system templates.
- The template language The Exponential 6 template language: template code in curly brackets, variables, operators, functions, comments and literal blocks.
- Designs and design order Designs and the design chain of a siteaccess in Exponential 6: SiteDesign, AdditionalSiteDesignList, designs in extensions and the order in which templates are looked up.
- The template override system The template override system of Exponential 6: override rules in override.ini, the match conditions, Priority and which rule wins.
- The pagelayout The pagelayout of Exponential 6: the main template, a minimal example, cache blocks, other pagelayouts and the debug report.
- Basic template tasks Basic template tasks in Exponential 6: include, escaping with wash, joining strings, translatable texts and view parameters.
- Information extraction Reading data in Exponential 6 templates with fetch: one node, lists of children, filters, sorting and paging.
- Template caching and cache-block Compiled templates, the content view cache and cache-block in Exponential 6 templates: what is cached, the keys and expiry, and what to clear after a change.
- Template security and wash Escaping output in Exponential 6 templates with wash: what to wash, the xhtml, javascript and email modes, and the same in Smarty and Twig templates.
- Template engines The three template engines of Exponential 6.0.15: Exponential templates, Smarty 5 and Twig 3, how to use them, mix them and convert designs between them.
- The Template Editor The Template Editor in the Design tab of the Exponential 6 administration interface: the template list, override cards and their order, new overrides and editing template files.
- Debugging templates Debugging Exponential 6 templates: the Exp Debug bar and its template tree, the list of used templates, template path comments and exp:template:check.
Contributors
- Balazs Halasy
- Graham Brookins Updated Maintainer
Comments
Add a comment