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

  1. Create a custom module providing at least one pattern in the file module.patterns.yml
  2. Enable the ui_patterns_library module
  3. 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 defined when rendering the pattern

Proposed resolution

Use the provider set by the pattern if ine exists and fall back to using the base plugin proivider.

Command icon 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

auth created an issue. See original summary.

auth’s picture

Status: Active » Needs review
StatusFileSize
new802 bytes

Attached is a patch impolementing the proposed resolution

auth’s picture

Issue summary: View changes
andyd328’s picture

Priority: Normal » Major

The 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.

pdureau’s picture

Hello 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?

robert dearmond’s picture

I 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

duaelfr made their first commit to this issue’s fork.

duaelfr’s picture

Assigned: auth » Unassigned

Converted the patch in a MR to let the CI do its magic

  • duaelfr committed de8128f1 on 8.x-1.x
    Issue #3419974 by auth: Patterns provider is always set to the...
duaelfr’s picture

Status: Needs review » Fixed

Existing tests are stable. Let's merge this before moving on to the next major.

duaelfr’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.