Compatibility with Layout Builder

Created on 2 July 2023, 12 months ago
Updated 1 May 2024, about 2 months ago

Problem/Motivation

I tried to use this module with "Layout Builder". it works with "Content Type" but not "Comment Type" or "Commerce Order Type"

Steps to reproduce

Enable "Layout Builder" in "Comment Type" or "Commerce Order Type" (Tested with these 2 Types) When click on "Manage layout" I got an error below :

AH01071: Got error 'PHP message: Uncaught PHP Exception Twig\\Error\\LoaderError: "Template "modules/contrib/manage_display/templates/field--node--uid.html.twig" is not defined." at themes/contrib/d8w3css/templates/block/block.html.twig line 44', referer: https://aa.aa.com/admin/structure/comment/manage/customer_comment/display

AH01071: Got error 'PHP message: Uncaught PHP Exception Twig\\Error\\LoaderError: "Template "modules/contrib/manage_display/templates/field--node--uid.html.twig" is not defined." at /aa/domains/aa.aa.com/public_html/core/themes/olivero/templates/block/block.html.twig line 52', referer: https://aa.aa.com/admin/commerce/config/order-types/default/edit/display

Workaround

A temporary fix is to duplicate the field.html.twig template to field--node--uid.html.twig and duplicate field.html.twig to field--node--created.html.twig in your custom theme.

๐Ÿ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @abx
  • I have the same type of error when using search:
    Twig\Error\LoaderError: Template "modules/contrib/manage_display/templates/field--node--uid.html.twig" is not defined. in Twig\Loader\ChainLoader->getCacheKey() (line 110 of core/themes/olivero/templates/content/comment.html.twig).

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

    Hi

    I Tested the module in both D9 and D10 for comment types and content type, When click on "Manage layout" it works fine in my local.
    I am attaching screenshots of it.'

    Thanks

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance PhilY ๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡ซ๐Ÿ‡ท Paris, France

    I face same kind of error using Drupal 10.1.2 with stock node full display mode (no Layout Builder), either with Olivero or a Radix child theme.
    Disabling or removing the comment field from my content type display mode removes the error.

    A temporary fix was to duplicate the field.html.twig template to field--node--uid.html.twig in my custom theme (or to write your own twig as long as the file exists).

    Then another similar error yells about missing field--node--created.html.twig file.
    Again, duplicating the field.html.twig template to field--node--created.html.twig fixes it.

    I've also tried uninstalling manage_display module by curiosity: it removed the 'Written by' (uid) and 'Written on' (created) fields from content type form displays and view modes!!!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cedewey Denver, CO

    Thanks PhilY for sharing that temporary workaround. I've updated the issue summary with that info. I am also experiencing this issue with trying to display comments on my site.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cedewey Denver, CO
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States timb

    I ran into this error when trying to view a feeds node. Fix was to copy and rename template files into custom theme:
    field--node--created.html.twig
    field--node--uuid.html.twig

  • First commit to issue fork.
  • Merge request !11#3371841 - Add templates โ†’ (Merged) created by AstonVictor
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 5 months ago
    2 pass
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    Created a new MR to fix it.

    It comes from the manage_display_theme() function. It adds new themes but doesn't provide templates in the /templates folder.

    I copied all required templates from the node/templates folder to the module folder.

    Please, review if it works.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    Thanks.

    I don't really understand why there is a problem. The new themes have a base hook, so why isn't the base template used?

    Unfortunately I don't think the patch works. When field--node--uid.html.twig is missing, the field display will fallback to field.html from the theme. After this patch it uses a copy of field.html from Core. So for example it can be missing some classes.

  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 5 months ago
    2 pass
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    I updated the MR by adding 'path' property to themes.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    Thanks, that's an interesting idea. Did you test that it works in the case from #12, when field--node--uid.html.twig is missing?

    Before the patch it would use field.html from the theme.

    Perhaps with this patch it would use field--node--uid.html from the node module?? This could cause a problem on upgrading existing sites.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    I checked Drupal 8, 9 & 10 versions and all of them contain field--node--uid.html template in the node module.

    I didn't find in core examples where the theme has a 'base hook' and doesn't have a template for the theme.
    e.g.
    - block__system_menu_block theme has 'base hook' => 'block', and has block--system-menu-block.html.twig template in the same module;
    - field__comment theme has 'base hook' => 'field', and has field--comment.html.twig template in the same module.

    I guess 'base hook' means which preprocess functions should be included for the theme.

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    Thanks I agree with everything in #16. My question is about this case.

    The site uses a custom theme which provides templates for field, field--node--uid but not field--uid.

    The site has an entity type called zzz with a field called uid that is not ever inline. What template is used?

    • My guess is before the patch is was field from the theme.
    • What about after? Does is still {% include "field.html.twig" %} from the custom theme??
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    > Compatibility with Layout Builder

    I don't think it is related to the layout builder module. I have Twig\Error\LoaderError: Template "modules/contrib/manage_display/templates/field--node--uid.html.twig" is not defined. error with disabled layout builder.

    my steps on the clean Drupal 10.1.5 site with Olivero theme:
    1. create a new article node
    2. add a new comment

    result: I see the fatal error. the error comes from $variables['author_name'] = $renderer->render($variables['author_name']);
    line of template_preprocess_submitted() function.

    > The site uses a custom theme which provides templates for field, field--node--uid but not field--uid.
    It should be configured via theme suggestions.

  • Status changed to Postponed: needs info 4 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    > I don't think it is related to the layout builder module.
    Sure then please update the IS๐Ÿ˜ƒ. I don't see the problem on any of my sites without layout builder so please provide a sequence of steps to reproduce that should work for me too.

    > It should be configured via theme suggestions.
    Please assume a standard install of Drupal Core and this module: the only hook_theme_suggestions() implementations are from that.

    The question in #12/#15/#17 is essential for me as part of the review process. I don't know what else I can do to explain it๐Ÿ˜ƒ. We need to understand if this patch would change the behaviour of this module, altering which templates are used for existing sites.

  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    > The question in #12/#15/#17 is essential for me as part of the review process. I

    as for me, It looks the same because fields use the same theme.
    I enabled twig debug and attached a screenshot (suggestions.png ) to show you that they use templates from the node module.

  • Status changed to RTBC 2 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AdamPS

    Yes it's good, very clever thanks.

    Currently there are no more NR, and 2 are RTBC ready to merge (including this one). Please let me know when you are ready for me to create a new release.

  • Status changed to Fixed 2 months ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine AstonVictor

    this task can be closed.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024