This issue the result of conversations at the Drupaldelphia2019 Layout BoF session.
Problem/Motivation
There are a number of issues that may be addressable (comparatively easily?) with a change in the Layout architecture:
- Unable to clone overridden layouts
- Layouts on Content Types treated as Configuration, but Layouts on Nodes treated as Content
- Unable to reuse Layouts across Content Types
- Unable to list Layouts used across system
Proposed resolution
Instead of making Layouts settings that are attached to Content Types or Nodes,
- make Layouts a "first level" config entity
- provide an /admin/structure/layouts administrative interface to define layouts
- for each Layout, provide a way to define the Context(s) that use that layout (eg: Context="All [Article, Basic] content types and NID [5,10]")
- Define a Weight for each Layout so if what is being rendered's context matches multiple layouts we know which one to select.
- Context selection could be done similar to the core Block module's context options (Content Type, Pages, Roles) or via the Context module.
This would allow Layouts to be centrally defined and managed, provide for easy reuse of Layouts across the system by any desired context, and all Layouts would become exportable configuration entities instead of being attached to individual nodes, while still having even more flexibility than we do now.
The UI for defining content type layouts (eg: Context="ContentType=Article") and overriding node Layouts could remain as-is, but instead of attaching the Layout info to the node, it would create a new Layout configuration entity with (eg: Context="NID=1234").
Having an Add Layout option on the /admin/structure/layouts page would pair well with
#3054056: When editing the layout for a content view mode, allow picking a specific node to use as the preview β
for showing placeholder data. Some UI magic could be done to filter the available blocks down to whatever entity is being previewed to reduce the amount of fields to pick from.
Remaining tasks
- Define new Context configuration entities
- Create Layout Listing admin page - could display Layout Name, Layout Description, Machine Name, Context fields, Links to Edit Layout, Links to Content (for node overrides)
- Create Add Layout admin page (or else only use the existing Content Type and Override layouts UI)
- Update Umami layouts to use new system
User interface changes
- Add new admin screens as described above.
- Existing interface would be visually unchanged.
API changes
TBD
Data model changes
TBD
Release notes snippet
Change Layout into first-order configuration entity, allowing all layouts to be reusable and exportable configuration entities.