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.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | suggestions.png | 90.26 KB | astonvictor |
| #4 | D10_ manage_layout_in_comment.png | 163.43 KB | dineshkumarbollu |
| #4 | D9_manage_layout_in_comments.png | 136.07 KB | dineshkumarbollu |
Issue fork manage_display-3371841
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
Comment #2
badmothergoose commentedI 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).
Comment #4
dineshkumarbollu commentedHi
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
Comment #5
philyI 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.twigtemplate tofield--node--uid.html.twigin 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.twigfile.Again, duplicating the
field.html.twigtemplate tofield--node--created.html.twigfixes 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!!!
Comment #6
cedeweyThanks 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.
Comment #7
cedeweyComment #8
timb commentedI 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
Comment #11
astonvictor commentedCreated 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/templatesfolder.I copied all required templates from the node/templates folder to the module folder.
Please, review if it works.
Comment #12
adamps commentedThanks.
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.
Comment #13
adamps commentedComment #14
astonvictor commentedI updated the MR by adding
'path'property to themes.Comment #15
adamps commentedThanks, 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.
Comment #16
astonvictor commentedI checked Drupal 8, 9 & 10 versions and all of them had
field--node--uid.htmltemplate 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_blocktheme has'base hook' => 'block',and hasblock--system-menu-block.html.twigtemplate in the same module;-
field__commenttheme has'base hook' => 'field',and hasfield--comment.html.twigtemplate in the same module.I guess 'base hook' means which preprocess functions should be included for the theme.
Comment #17
adamps commentedThanks 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?
fieldfrom the theme.Comment #18
astonvictor commented> 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 oftemplate_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.
Comment #19
adamps commented> 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.
Comment #20
astonvictor commented> 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.
Comment #21
adamps commentedYes 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.
Comment #23
astonvictor commentedthis task can be closed.