
Problem/Motivation
Upgraded from Drupal 9.5.9 running Components v8.x-2.4 to Drupal 10.0.10 Components 3.0.0-beta3.
Site has multiple active front-end themes:
- Contributed Theme A
- Custom Theme B
- Custom Theme C (Default Theme)
Each theme registers it's own components namespace within it's own theme.info.yml. Note we are using the new API format already for example:
components:
namespaces:
theme_c: ./src/components
These namespaces are referenced throughout templates within the themes and within our custom modules. Sometimes we reference components in Theme A or Theme B within a template used in Theme C.
For example in our node.html.twig file within Theme C (default theme):
{% extends "@bc_base/node/node.twig" %}
We discovered after upgrading that only the default theme's name spaces can be referenced in this manner, and other active theme namespaces no longer work. Instead we receive errors:
The website encountered an unexpected error. Please try again later.
Twig\Error\LoaderError: Template "@theme_b/node/node.twig" is not defined in "themes/custom/theme_c/templates/content/node.html.twig" at line 7. in Twig\Loader\ChainLoader->getCacheKey() (line 99 of /var/www/html/drupal-site/html/vendor/twig/twig/src/Loader/ChainLoader.php).
Twig\Environment->getTemplateClass('@theme_b/node/node.twig', NULL) (Line: 204)
Drupal\Core\Template\TwigEnvironment->getTemplateClass('@theme_b/node/node.twig') (Line: 319)
Twig\Template->loadTemplate('@theme_b/node/node.twig', 'themes/custom/theme_c/templates/content/node.html.twig', 7) (Line: 42)
__TwigTemplate_e00c24621e5aa37876799c6770b633e0->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('themes/custom/theme_c/templates/content/node.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 168)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 692)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Activate multiple themes, each with their own namespaces defined within their own theme info.yml
- Reference a template in a non-default theme via it's namespace... works fine
- Switch from Components v8.x-2.4 to Components 3.0.0-beta3.
- Note namespaces no longer work
Our workaround for now, is to include all the namespaces for the other active themes within the default theme's info.yml file.
For example:
components:
namespaces:
theme_c: src/components
theme_b: ../theme_b/src/components
theme_a: ../../contrib/theme_a/src/components
Proposed resolution
According to the module description, namespaces from all active themes should work, not just default theme. Has any one run into this issue? It does not appear related to any open tickets.
Comments
Comment #2
nicklundy CreditAttribution: nicklundy at Millennium Communications commentedComment #3
nicklundy CreditAttribution: nicklundy at Millennium Communications commentedComment #4
talisa1987 CreditAttribution: talisa1987 at Drupal Ukraine Community commentedI have the same issue. Still looking for solution
Comment #5
pmkanse CreditAttribution: pmkanse as a volunteer and for Interpersonal Frequency commentedAny update on this?
Comment #6
pmkanse CreditAttribution: pmkanse as a volunteer and for Interpersonal Frequency commentedAfter changing entry in .info.yml file and clearing cache, its started working for me.
Changes are as below
BEFORE :
AFTER :
Comment #7
nicklundy CreditAttribution: nicklundy at Millennium Communications commentedpmkanse are you running multiple active themes?
Comment #8
abhinesh@nicklundy, Thanks for creating the issue, I am too facing this issue with theme extending one other theme.
Comment #9
kristen polThanks for reporting this! I just got bit by this one.
Regarding #6, we were already using the proper syntax so it's not that for us.