Designs and design order
A design is a folder of templates and the files they use. Each siteaccess uses a chain of designs, and every template, image and stylesheet is looked up in that chain: the first design that has the file wins. This page describes the chain and how to read it on your installation. The concept is introduced in Designs of the Concepts and basics chapter.
What a design contains
design/<name>/templates/ templates: pagelayout.tpl, node/view/full.tpl, user/login.tpl ... design/<name>/override/templates/ override templates, chosen by rules in override.ini design/<name>/stylesheets/ design/<name>/images/ design/<name>/javascript/
A design can also live in an extension, as extension/<extension>/design/<name>/. That is the recommended place for your own design: it is kept apart from the kernel, it can be versioned and installed like any extension, and it survives an upgrade untouched.
The design settings
Three settings of site.ini [DesignSettings], set per siteaccess in settings/siteaccess/<siteaccess>/site.ini.append.php, make the chain:
| Setting | Meaning | Default |
|---|---|---|
| SiteDesign | The main design of the siteaccess, searched first. | admin (each siteaccess sets its own) |
| AdditionalSiteDesignList[] | Further designs, searched in the order listed. | empty |
| StandardDesign | The last design of the chain, the fallback for everything. | standard |
<?php /* #?ini charset="utf-8"? [DesignSettings] SiteDesign=example AdditionalSiteDesignList[] AdditionalSiteDesignList[]=ezwebin AdditionalSiteDesignList[]=base */ ?>
The empty AdditionalSiteDesignList[] line first clears the list inherited from the files read before. A design named twice is searched only at its first place.
Designs in extensions
An extension whose design folders should be searched names itself in design.ini [ExtensionSettings] DesignExtensions[], usually in its own settings/design.ini.append.php:
[ExtensionSettings] DesignExtensions[]=myextension
The search order
For each design of the chain (SiteDesign, then AdditionalSiteDesignList, then StandardDesign), Exponential looks first in the design folders of the extensions in DesignExtensions, starting with the extension listed last, and then in design/<design>/. For the chain above and two design extensions, the folders are searched in this order:
extension/ext_b/design/example/ (DesignExtensions[]=ext_a, then ext_b: the last listed comes first) extension/ext_a/design/example/ design/example/ extension/ext_b/design/ezwebin/ ... design/standard/
Only folders that exist are in the list. The order of DesignExtensions follows the order in which the extensions' settings are read, which the order of ActiveExtensions decides; see Extension loading order.
The list decides two things:
- A plain template, such as user/login.tpl or pagelayout.tpl, is taken from the first folder whose templates/ has it.
- An override template named in a rule (MatchFile) is taken from the first folder whose override/templates/ has it. Whether an override is used at all is decided by its rule, not by where the file is; see The template override system.
Images and design files found with the operators ezimage and ezdesign are looked up in the same order (see URL handling).
Read the chain of a siteaccess
The console shows the value in effect and every file that sets it:
./console exp:ini where site/DesignSettings/SiteDesign eng ./console exp:ini where site/DesignSettings/AdditionalSiteDesignList eng ./console exp:ini where design/ExtensionSettings/DesignExtensions eng
Replace eng with your siteaccess, and add --allow-root-user when you run it as root. In the browser, template path comments and the list of used templates show which file of which design answered (see Debugging templates).
Caching of the chain
With site.ini [DesignSettings] DesignLocationCache=enabled (disabled by default) the list of design folders is cached per siteaccess; clear it with php bin/php/ezcache.php --clear-id=design_base after adding a design folder. A new template at a path no design had before needs the template override cache cleared: --clear-id=template-override. See Template caching.
Choosing a design per visitor
A front siteaccess can let visitors switch between designs: site.ini [DesignSettings] SwitchableDesigns[] lists the designs, and a link with the view parameter /(design)/<name> chooses one, kept in a cookie. It is off while the list is empty. See Front design switch. In the administration interface, a signed-in user with the policy uiswitch/design can choose an administration design for themselves; see UI switch: design.
Contributors
- Graham Brookins Updated Maintainer
Comments
Add a comment