Two ways to build
Exponential 6.0.15+ gives a site two ways of being built, and most real sites use both at once.
| 1. Templates in a design extension | 2. The Layouts editor | |
|---|---|---|
| What you make | .tpl files, stylesheets, settings, in your own extension | Layouts: zones filled with blocks, stored in the database |
| Tool | an editor, a terminal, git | the administration's Layouts tab (in the top menu, or under More when the menu has no room for it) |
| Who | designers, developers | website creators, editors, administrators |
| Changes go live | after deploy and a cache clear | when you press Publish layout |
| Versioned | in git with your extension | drafts and published versions in the database; export and import as .zip (exp:layouts) |
| Reach | everything: markup, data, logic | what the block types and their view types offer |
Contents
- Way 1: templates in a design extension
- Way 2: the Layouts editor
- Where the two meet
- A third tool: settings
- Which way when
- What it costs, measured
Way 1: templates in a design extension
A design is a folder of templates under extension/<name>/design/<design>/templates/. The Fit & Healthy site is the
design media of the extension sevenx_themes_media. Every part of a page is a template there:
pagelayout.tpl (the HTML page), pagelayout/header.tpl, pagelayout/footer.tpl, the content views under
content/views/, the block templates under explayouts/block/.
A template that another extension provides is changed without touching it: put a file with the same path in your own
design extension, listed later in design.ini [ExtensionSettings] DesignExtensions[] (the last one listed wins), and
clear the template caches. Templates use Exponential's template language: {def}, {foreach}, fetch(), ezini(),
|wash, |ezurl.
Choose it for anything structural: the HTML of the page, a new kind of block, a view of a content class, a menu that fetches its items, markup that must be the same on every page.
Way 2: the Layouts editor
Layouts in the administration builds pages from blocks, by drag and drop. The Layouts tab of the top menu
(under More when the menu has no room for it) opens the Layouts dashboard; its left menu has Layout mappings,
Layouts, Shared layouts, Components, Export, Import and Template editor, and New layout on
the dashboard opens the editor. A layout has a type (its zones: for example header, post_header, main,
pre_footer, footer) and holds blocks in its zones. The editor offers the block types defined in
explayouts.ini (Title, Text, Rich text, Image, Button / Link, List, Grid, Gallery, Slider, Hero, Card, Two columns,
Three columns, Four columns and more), each with its view types and options. Layout mappings decide which layout
a page gets: by node, subtree, path or route, narrowed if needed by conditions such as the content class, the
siteaccess or a time span.
Choose it for page composition: landing pages, campaign pages, a hero and three teasers, a list of the newest articles, the blocks above the footer, anything an editor should be able to rearrange without a release.
Where the two meet
The two ways are one system:
- Every block is rendered by a template:
design:explayouts/block/<block type>.tplin the design. Change that template in your extension and every block of that type changes, everywhere. - A Template block is a block whose content is a template you name. That is how the shared layout Header / Footer puts the theme's header and footer into every layout: the layout decides where, the template decides what (How the header is built).
- Shared layouts with linked zones let one set of blocks appear on many page types (Shared layouts and zone linking).
- The templates read content with
fetch(), the blocks read it through collections (hand-picked items or a query on the tree). Both show the same content tree.
A third tool: settings
Some things are neither: the header menu of this theme is a list of node IDs in menu.ini, read by the header
template. Settings are changed in Setup > Ini settings (the group System of the Setup menu) or with
./console exp:ini, no code (Add a header menu item).
Three things of the administration come up on almost every page of this guide:
- The right column has the Clear cache box (choose, for example, Template & content, then Clear) and,
further down, Quick settings for the debug switches such as List of used templates, with a Siteaccess
choice and Set. The address
setup/settingstoolbarof the administration shows the same switches as a page of its own, Quick settings. - Content is added in Content structure (or Media for the footer links): open the parent and press Create new above its sub items; the menu lists the classes by group (Netgen holds Landing page and Menu item, Content holds Folder).
- The ? button in the top bar has Help for this page and Open the Help center, where this guide and the rest of the help can be searched.
Which way when
The full table is on Which way: the decision table. In short:
| If the change is | Use |
|---|---|
| Where blocks are and which ones | Layouts editor |
| What a block type looks like everywhere | Template override of explayouts/block/<type>.tpl |
| The site's chrome (header, footer, page HTML) | Templates; place it with a template block |
| The header or footer menu entries of this theme | Settings (menu.ini) or, for the footer's second line, content |
| A new kind of block | Both: a block definition in explayouts.ini plus its template, then the editor offers it |
What it costs, measured
On a throwaway copy of the installation (PHP's built-in server, a shared host under load):
| Task | Way | Steps | Time measured |
|---|---|---|---|
| Add a header menu item | Administration (settings) | 10 actions | |
| Add a header menu item | Console | 2 commands | 1.3 to 2.1 s + 2.0 to 2.5 s |
| Add a footer link | Content tree | 9 actions, no cache clear | |
| First page after a full template and content clear | 2.9 to 3.4 s | ||
| A page from the page cache | 22 to 102 ms |
How these were counted: Measured steps and times.
Related pages
- Two ways to build, every page
- Which way: the decision table
- Life-cycle examples: 206 tasks from planning to migration, each done both ways
- Build a campaign page, start to finish
- Add a header menu item
- The layouts editor
- 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.