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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abx created an issue. See original summary.

badmothergoose’s picture

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).

dineshkumarbollu made their first commit to this issue’s fork.

dineshkumarbollu’s picture

StatusFileSize
new136.07 KB
new163.43 KB

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

phily’s picture

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!!!

cedewey’s picture

Issue summary: View changes

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.

cedewey’s picture

Issue summary: View changes
timb’s picture

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

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Active » Needs review

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.

adamps’s picture

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.

adamps’s picture

Status: Needs review » Needs work
astonvictor’s picture

Status: Needs work » Needs review

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

adamps’s picture

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.

astonvictor’s picture

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

I didn't find in core examples where the theme had a 'base hook' and didn'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.

adamps’s picture

Title: LoaderError Template field--node--uid.html.twig » Compatibility with Layout Builder
Category: Support request » Task
Status: Needs review » Needs work

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??
astonvictor’s picture

Status: Needs work » Needs review

> 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.

adamps’s picture

Status: Needs review » Postponed (maintainer needs more info)

> 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.

astonvictor’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new90.26 KB

> 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.

adamps’s picture

Status: Needs review » Reviewed & tested by the community

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.

astonvictor’s picture

Status: Reviewed & tested by the community » Fixed

this task can be closed.

Status: Fixed » Closed (fixed)

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