Override basics
This page is for designers who want a different template for some content: articles, one special page, everything in
a section. An override is a rule: "when the template Source is used for content that matches these conditions,
use MatchFile instead".
Contents
- A rule
- Where rules live
- How the replacement is found
- When several rules match
- Managing overrides in the administration
- Caches
A rule
[mytheme_full_article]
Source=node/view/full.tpl
MatchFile=full/article.tpl
Subdir=templates
Match[class_identifier]=article
Priority=10| Key | Meaning |
|---|---|
| section name | unique name of the rule; prefix it with your theme |
Source | the template being replaced, a path under templates/ |
MatchFile | the replacement, a path under override/templates/ |
Subdir | templates (the folder kind; always this value in designs) |
Match[<key>] | conditions; all must be true (Override match keys); none means always |
Priority | order of evaluation, lowest first; rules without one come last (Override ordering) |
The kernel's settings/override.ini shows the syntax as a commented example and holds no rules itself.
Where rules live
Rules are read from override.ini with all its append files, for the current siteaccess:
settings/siteaccess/<siteaccess>/override.ini.append.php(the siteaccess's own);- an extension's
settings/override.ini.append.php(every siteaccess where the extension is active); - an extension's
settings/siteaccess/<siteaccess>/override.ini.append.php(that siteaccess only; how the media and starter themes ship theirs).
Prefer the extension's siteaccess file for a theme: its rules then never touch the administration or other sites.
How the replacement is found
When Source is requested, the kernel checks the rules for it in order; the first whose conditions all match wins. Its
MatchFile is searched under override/templates/ in every design base of the cascade
(eZTemplateDesignResource::overrideArray() in kernel/common/eztemplatedesignresource.php). A MatchFile found in
no design is reported in the error log ("Custom match file: path ... not found in any resource").
When several rules match
Only the first rule in order counts. Give specific rules (one node) a lower Priority than general ones (a class), so
they are checked first. See Override ordering.
Managing overrides in the administration
Design > Template Editor (/visual/templatelist) lists the templates of a siteaccess with their overrides, creates
new ones (written with Priority=0), reorders them by drag and drop and edits the files
(Template editor: create, order and edit overrides). For a theme in
an extension, keep the rules in the extension's files, under version control.
Caches
After adding a rule or an override template: php bin/php/ezcache.php --clear-tag=ini and
--clear-id=template-override. Then --clear-id=content for full views already cached.
Related pages
- Override match keys
- Node templates by class
- Tutorial: override a full view
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
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.