Skip to content

Layout templates ​

What it does ​

A template is a whole page that new pages start from. A page that starts from a template gets a copy of its items: from then on the page is its own, and a change of the template does not reach it.

A saved blockA presetA template
What it isone block with everything in itthe values of one component's optionsa whole page
On a pagelinked, shown as it is savedthe block follows it, with values of its owncopied once, when the page starts from it
Contentthe block'sthe block's own (a preset can give starting content, copied)the page's, from the start

Content that every page started from a template must share (a banner, a call to action) is a block of the library placed in the template: the pages link to it, as anywhere, and a change of the block shows on all of them. A preset in a template works the same way: the copies on the pages follow it.

Limitations ​

  • A page gets a copy: a later change of the template does not reach pages that started from it. Share content through a block of the library placed in the template.
  • Paragraph blocks are left out of a template: a paragraph belongs to one page.
  • A template has no drafts in the history of a page, no revisions and no translations.
  • A template that pages started from cannot be deleted, only archived.
  • The AI assistant is not told about templates.
  • The editor of a template has no copy and paste yet.

Content types, status ​

A template is a whole page to start from. An empty page shows a hint in the middle of the canvas with the page templates of its content type, and a search when there are more than a few. How an entity looks in a list or a reference is not a template: it is the layout of a display, see Layouts per Manage display.

  • A template is offered for the content types it names (none: all of them).
  • A template is Active or Archived.

In the editor ​

Making a template ​

the Template button in the top bar. The dialog asks for a name, a description and the content types. The whole page becomes the template; the page itself stays as it is. Paragraph blocks are left out of a template: a paragraph belongs to one page.

Making templates needs the permission Manage Frame templates.

Starting a page from a template ​

An empty page lists the page templates of its content type in the middle of the canvas, with a search when there are many. Choosing one puts a copy of its items on the page, with new ids: blocks of the library stay linked, blocks that follow a preset keep following it, everything else is the page's to change. The page remembers the template it started from (root.props._template).

Editing a template ​

Content > Frame > Templates > Edit (/admin/content/frame/templates/{id}/edit, the edit address of the entity) opens the editor on the template itself, the same editor as for a page, without the page form: with nothing selected the right column has the template's settings (name, description, kind, content types). Save stores the layout and the settings; there are no drafts, revisions or translations. Pages that started from the template earlier keep what they have.

A Field block in a template has no page to take its value from while the template is edited: it shows its Example (text, or an image, set in its form), or without one a placeholder with the label of the field. Pages made from the template show their own field and never the example, and the template cards do not show it either.

Archive instead of delete ​

A template that pages started from cannot be deleted; it can be archived. An archived template is no longer offered for new pages, and an archived card keeps working where it is shown. It can be restored. It can be deleted when nothing refers to it; the delete form names the pages that do and offers to archive it instead (the same refusal is in the API: 409, and in Template::preDelete()).

The list ​

Content > Frame > Templates (/admin/content/frame/templates) lists the templates: name, content types, status, Used on (the number of places), when it changed, with Edit (the editor), Settings (the entity form: name, description, content types, status), Used (a tab next to Edit, /admin/content/frame/templates/{id}/used, with a link to every place that uses it), Archive or Restore, Export and Delete. It is narrowed by status with ?status=active or ?status=archived.

Where a template is used is counted like the library's (Entity Usage when installed, else the entity frame_usage): a page uses the template it started from (root.props._template). What a template holds (media, links, presets, blocks of the library) counts for the template, and for each page as its copy.

Permissions ​

PermissionAllows
Create or edit a page that uses the editorStart a page from a template
Manage Frame templatesSave as template, edit, archive, restore, delete, the list in the admin

Component versions ​

Templates are migrated with the content when a component changes (Versions and migrations): the items of every template, archived ones too, go through the steps. A page that starts from a template gets the items at the current version.

Export and import ​

A layout file includes the template a page started from in includes.templates, and names it in root.props._template. See Export and import. A template has its own Export tab.

How it is stored ​

A template is a content entity, frame_template (class Template): a name, a description, the kind (page or card), the content types (a JSON list), the status (active or archived), the layout in the field frame_layout (the same field and format as a page's), and a log of saves. Templates (the service frame_editor.templates) reads and writes them, and makes the copy a page starts with (Templates::instantiate()). The editor opens on it with the same controller as for a page (BuilderController::editorEntity(), saveEntity()), which works on any entity that has the field frame_layout; LayoutStorage reads and stores the layout of such an entity too. Existing sites get the entity type with drush updb (frame_editor_update_11010).

For the AI assistant ​

The assistant is not told about templates: a template is where a page starts, not something to build with. It uses blocks of the library and presets as on any page. See AI assistant.