Template is not defined error on node edit / admin pages

Created on 22 January 2020, almost 5 years ago
Updated 16 March 2023, almost 2 years ago

Problem

After updating to Drupal 8.8.1 I'm getting the following error:

Twig\Error\LoaderError: Template "@organisms/header-top/header-top.twig" is not defined in "themes/custom/aedt_theme/src/templates/layout/region--header-top.html.twig" at line 9. in Twig\Loader\ChainLoader->getCacheKey() (line 142 of vendor/twig/twig/src/Loader/ChainLoader.php).

This is my setting in my theme's .info file:

component-libraries:
  organisms:
    paths:
      - src/_patterns/03-organisms

And this is how the region--header-top.html.twig file looks like:

{% if content %}
  {% include '@organisms/header-top/header-top.twig' with {
    'content': content,
    'attributes': attributes
  } %}
{% endif %}

Before the update, this worked just fine but now it's throwing the template not defined error.
Is there something I need to add or change in my .info file? I've tried about everything but no dice.

Steps to reproduce

  • Define a component namespace in your theme
  • Create a page template that embeds another component using that namespace
  • Login as a user with permission to view the admin theme
  • Setup a custom 403 page
  • Try to edit a node you don't have permission to use, by default this will have the admin theme as the active theme, but triggers the 403 subscriber to make a subrequest and render the page template using the front-end theme
  • Put a breakpoint in \Drupal\components\Template\Loader\ComponentsLoader::findTemplate and see that the active theme is still seen as the admin theme, and hence the front-end theming of the 403 page in the subrequest fails
๐Ÿ› Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium inge_dt

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

Merge Requests

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