Layout template suggestions are not loaded properly

Created on 27 September 2017, about 7 years ago
Updated 25 June 2024, 4 months ago

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


@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

  1. #11
  2. Code a solution
  3. 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.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Layout discovery 

Last updated 4 months ago

No maintainer
Created by

🇮🇹Italy gambry Milan

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024