Problem/Motivation
When using ui_patterns_library to find patterns defined in another module using the file module.patterns.yml the templates are not found when rendering since the provider is set to ui_patterns_library instead of the module providing the module.patterns.yml file.
Steps to reproduce
- Create a custom module providing at least one pattern in the file module.patterns.yml
- Enable the ui_patterns_library module
- Notice that the site throws the error
Twig\Error\LoaderError: Template "modules/contrib/ui_patterns/modules/ui_patterns_library/templates/pattern-template-name.html.twig" is not definedwhen rendering the pattern
Proposed resolution
Use the provider set by the pattern if ine exists and fall back to using the base plugin proivider.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3419974-patterns-provider-is-always-set-to-the-base_plugin_definition-provider-2.patch | 802 bytes | auth |
Issue fork ui_patterns-3419974
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:
- 3419974-patterns-provider
changes, plain diff MR !389
Comments
Comment #2
auth commentedAttached is a patch impolementing the proposed resolution
Comment #3
auth commentedComment #4
andyd328The patch work for me. Many thanks auth.
Changing to major as it really is important to pick up custom patterns, borderline critical as it breaks the parts of a site without this patch.
Comment #5
pdureau commentedHello guys,
Thanks for your contribution. The issue you met may be a side effect of #3314789: Fix views preview when pattern declared by ui_pattern_library in the front theme.
I would not do the review myself, because this subject is a bit tricky to me. I am afraid if we fix one stuff here, we will have a side effect somewhere else.
Is applying the patch on your project good enough for now?
Comment #6
robert dearmond commentedI have been struggling with this same issue and finally found #2 patch works for me!
My error was:
Uncaught PHP Exception Twig\Error\LoaderError: "Template "modules/contrib/ui_patterns/modules/ui_patterns_library/templates/pattern-page-body.html.twig" is not defined." at /code/web/modules/contrib/ds/templates/ds-entity-view.html.twig line 10
Comment #9
duaelfrConverted the patch in a MR to let the CI do its magic
Comment #11
duaelfrExisting tests are stable. Let's merge this before moving on to the next major.
Comment #12
duaelfr