Problem/Motivation
Layout discovery doesn't load layout suggestions unless the layout definition is prefixed with layout__
and the template with layout--
.
This break any existing site using the (deprecated) Layouts contrib module, where the prefixing wasn't necessary.
Additionally site-builders and developers get confused as twig debug comments suggest wrong [as in: not-prefixed] template suggestions names, i.e. (from: #2905197: Template override is not working):
layouts definitions file: naurodvolleys.layouts.yml
naurodvolleys_1x1:
label: "naurodvolleys 1x1"
category: "naurodvolleys"
template: "templates/content-layout/naurodvolleys_1x1"
regions:
main:
label: "Main"
Template suggestions:
![]()
Target suggestion: naurodvolleys-1x1--node-result-1x1.html.twig
![]()
Suggestion is not loaded.
For further investigation you can read #2862683: 'base hook' key prevents template suggestions from working comments from #25 on going.
Proposed resolution
The first task should be to understand if prefixing layouts with layout__/layout-- as core does is the right way.
- If it is then we need to update the documentation pages How to register layouts and How to upgrade from Layout Plugin, together with updating the twig debug comment suggestions.
- if it is NOT, then we need to fix the issue in order for layout suggestions to be loaded correctly.
@tim.plunkett on #9 confirmed this is actually a bug, themes and modules layout templates suggestions needs to be loaded in accordance with their definitions.
Remaining tasks
Define what is the right way to name layout bundles and their templates, if the layout__/layout-- prefixes are mandatory. (#9Update the issue summary with the right proposed resolution when task 1) is complete #11- Code a solution
- Update the documentation if necessary
User interface changes
This is a pure code change, so no UI changes expected.
API changes
There may be Layout API changes, depending what the result of task 1) will be.