- ๐บ๐ธUnited States AaronBauman Philadelphia
@JohnAlbin I don't think grabbing theme manager from
\Drupal::service()
will make a difference
ThemeManager
is instantiated at the beginning of the request, and itsdefaultTheme
property is statically initialized only once.So in order to get the proper theme on a sub-request, we need to re-instantiate Drupal's
ThemeManager
service every time prior to callinggetActiveTheme()
.
IMO this seems like a terrible waste of resources, and worthy of a fix in core, if this is indeed what's happening. - Merge request !32Issue #3107993 - Template is not defined error on node edit / admin pages โ (Open) created by AaronBauman
- Assigned to AaronBauman
- ๐บ๐ธUnited States AaronBauman Philadelphia
Opened new MR against 3.x https://git.drupalcode.org/project/components/-/merge_requests/32
First commit is test only, to demonstrate the issue.
Subsequently, I will update with the patch that's working for me.
- Status changed to Needs review
almost 2 years ago 4:23pm 17 March 2023 - ๐บ๐ธUnited States AaronBauman Philadelphia
OK, so comment #28 TEST ONLY demonstrates the bug.
And the MR addresses the bug thusly:
- If a given template is not found in the current active theme, and the active theme is not the default theme, also check the default theme.This change requires adding
ConfigFactory
to dependencies, so that we can grab the active theme.
If we think it's better to check ALL enabled themes, we could do that throughThemeExtensionList
without adding any new dependencies. - ๐บ๐ธUnited States ironsizide
The fixes in MR 32 are working for me nicely in Drupal 9.5.9.
- ๐ฎ๐ณIndia sanoopuio
I get this error on 3.0.0-beta3, not sure how to continue
- ๐ฎ๐ณIndia Sana.Neyazi
Hi @aronbauman, Could we know when we can expect Drupal 10 stable release
component
module? - Issue was unassigned.
- ๐บ๐ธUnited States AaronBauman Philadelphia
No commits on this project and no comments from maintainers for over a year ๐ฌ
Dunno what's happening but that's not a good sign.
- ๐บ๐ธUnited States yujiman85
I had the same issue with templates not being defined in Twigs using "extends" after the update to the latest version. It seems I was able to fix the situation by updating the namespaces in the info.yml file for my custom theme from the old API to the new one as per https://www.drupal.org/docs/contributed-modules/components/registering-twig-namespaces โ . Not sure if this will work for anyone else but worth a shot if your situation is at all similar.
Old:
component-libraries: [THEMENAME]: paths: - components
New:
components: namespaces: [THEMENAME]: - components
So far I haven't run into any breaking issues but if I do I'll come back to update
- ๐ฎ๐ณIndia sanoopuio
Thanks for hint, it works . https://www.drupal.org/docs/contributed-modules/components/registering-t... โ
# This example YAML creates 3 namespaces: @atoms, @quarks, @universecomponents: namespaces: # If your namespace only has one directory, # you can use this simple YAML syntax. atoms: library/atoms quarks: library/quarks
- last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago 62 pass - last update
over 1 year ago 62 pass - last update
over 1 year ago 62 pass - Status changed to RTBC
over 1 year ago 12:37pm 8 August 2023 - Status changed to Closed: works as designed
over 1 year ago 11:45pm 10 September 2023 - ๐บ๐ธUnited States yujiman85
Since this technically works like it's supposed to after changing how the namespaces are structured, I'm going to move this over to "Closed (works as designed)". If that isn't right someone please move it back. The documentation for the API is there but it's two clicks deep from the module page, maybe there could be a more noticeable section highlighting how to structure the namespaces? Especially now since the old way doesn't seem to work after moving to v3.
- Status changed to RTBC
over 1 year ago 1:52pm 11 September 2023 - ๐บ๐ธUnited States AaronBauman Philadelphia
I don't think this should be closed, as this issue persists even for themes whose namespace definitions have been update for the new API.
This is not a problem with implementations, this is a problem with Components! module's discovery system.The current MR includes a test to demonstrate the bug, as well as a resolution for it.
Issue summary updated and set back to RTBC - ๐ซ๐ฎFinland kekkis Pirkkala
RTBC +1. Created a local patch from MR in #28 and it fixes our problem which is exactly what the test describes.
- last update
about 1 year ago PHPLint Failed - ๐บ๐ธUnited States dgroene
Patch against 3.0.0-beta3 for those who meed it
- last update
about 1 year ago 35 pass, 2 fail - ๐บ๐ธUnited States dgroene
Patch from MR 32, without the testing changes
The last submitted patch, 45: components-template_undefined_on_admin_pages-3107993-45.patch, failed testing. View results โ
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- Status changed to Needs work
about 1 year ago 12:35pm 16 November 2023 - ๐บ๐ธUnited States raywalters
Applying the merge request patch in this issue along with the merge request from https://www.drupal.org/project/ui_patterns/issues/3335833 ๐ Patterns library doesn't detect other activated theme patterns (only from the basetheme) RTBC for ui patterns resolved my issue.
Twig\Error\LoaderError: Template "modules/contrib/ui_patterns/templates/pattern-teaser.html.twig" is not defined. in Twig\Loader\ChainLoader->getCacheKey() (line 10 of /var/www/html/docroot/modules/contrib/ds/templates/ds-entity-view.html.twig).
- ๐บ๐ธUnited States seanr
I just tested this and it doesn't seem to be working for me. Oddly, the same site in ddev on my local doesn't show the error, but on staging it does (same PHP versions, etc). Cleared caches, etc, but it works with or without the patch locally, and doesn't either way on staging. Any ideas?
- ๐ง๐ทBrazil RonanRBR Fortaleza-CE
Just adding the patch file for the brantch MR 3107993-3x-template-not-found https://git.drupalcode.org/project/components/-/merge_requests/32
I have resolved the same issue with the help of this hook:
function hook_components_namespaces_alter(array &$namespaces, string $theme) { if ('FRONT_END_THEME' === $theme) { return; } $theme_handler = \Drupal::service('theme_handler'); $registry = \Drupal::service('components.registry'); $namespaces = $registry->getNamespaces($theme_handler->getDefault()); }
So every other than the default front-end theme will use the same namespaces defined inside front-end-theme.info.yml.
I have tested it with ui_patterns and views and now all components are loaded with no issues under the admin theme.
- ๐บ๐ธUnited States aaronelborg
I ran into this issue after upgrading to Drupal 10. Fix seemed to be:
1) Upgrading to Components 3.1
2) installing symfony/css-selector and symfony/dom-crawler (you might not need to do this but I did)
3) adding this to my theme's info.yamlcomponents: namespaces: atoms: ../wingsuit/dist/app-drupal/atomic/patterns/01-atoms molecules: ../wingsuit/dist/app-drupal/atomic/patterns/02-molecules organisms: ../wingsuit/dist/app-drupal/atomic/patterns/03-organisms templates: ../wingsuit/dist/app-drupal/atomic/patterns/04-templates
Perhaps this will help someone else. Hope so!
- ๐ฎ๐ณIndia mohit_aghera Rajkot
mohit_aghera โ changed the visibility of the branch 3107993-3x-template-not-found to hidden.
- ๐ฎ๐ณIndia mohit_aghera Rajkot
mohit_aghera โ changed the visibility of the branch 3107993-3x-template-not-found to active.