0

When I try to edit a page to upload 2 documents, I get an error.

Procedure: I edit the node, upload the first document. Then I insert a new field to upload the second document. However, the second field does not appear and I get the following error message in dblog:

"Twig\Error\LoaderError: Template "themes/bootstrap_sbv/layout/sbv-personenseite-layout.html.twig" is not defined. in Twig\Loader\ChainLoader->getCacheKey() (line 10 of webpath/docroot/modules/ds/templates/ds-entity-view.html.twig).

I have tried to include the layout in the "ds-entity-view.html.twig" file.

{% include "/themes/bootstrap_sbv/layouts/sbv-personenseite-layout.html.twig" %}

But it doesn't work.

Curiously, everything works on the local environment. Only on the test and production environment I get the error. I have a custom theme on my Drupalsite.

  • Can you ensure that your template is present in the right location for non-working environments? – d70rr3s Jan 23 at 10:43
  • Not sure if it makes any difference, but instead of using an absolute path {% include '/theme/my_theme/dummy...' %} you can use a module's or theme's machine name as namespace {% include '@my_theme/dummy...' %} - this way you are safe if your modules/themes are split in .../contrib/... (from drupal.org) and .../custom/... (own code) sub-folders – Hudri Jan 23 at 11:11
  • I tried to add {% include "@bootstrap_sbv/layouts/sbv-personenseite-layout.html.twig" %} but get the following error Twig\Error\LoaderError: Template "@bootstrap_sbv/layouts/sbv-detail-page-layout.html.twig" is not defined in "modules/ds/templates/ds-entity-view.html.twig" at line 1. in Twig\Loader\ChainLoader->getCacheKey() (line 142 of /webpath/docroot/vendor/twig/twig/src/Loader/ChainLoader.php). – Zeroplexer Jan 23 at 13:01
  • @Zeroplexer after giving it a thought I notice that the error cames from DS module. It seems to me that is possible that you are using custom layouts and you have a typo on the template route for that layout. Check this drupal.stackexchange.com/questions/162482/… – d70rr3s Jan 23 at 14:20
  • 2
    Note that all Twig templates should always reside inside the /templates subfolder of your theme/module. – Hudri Jan 23 at 14:53
1

Moving the templates to the Templates folder themes/THEMENAME/templates has solved the problem. I also had to change the path in the THEMENAME.layouts.yml

| improve this answer | |
  • Please check your answer as "correct answer" so can be useful to others. – d70rr3s Jan 23 at 15:22
0

Pay attention to @my_theme syntax it refers to themes/my_theme/templates folder while the desired template is located into themes/my_theme/layouts folder.

So what I suggest is to use a relative path to include the template, something like that:

{% include '../../../themes/bootstrap_sbv/layouts/sbv-personenseite-layout.html.twig' %}

| improve this answer | |
  • Unfortunately it didn't work I get this error: Twig\Error\LoaderError: Template "@bootstrap_sbv/layouts/sbv-detail-page-layout.html.twig" is not defined in "modules/ds/templates/ds-entity-view.html.twig" at line 1. in Twig\Loader\ChainLoader->getCacheKey() (line 142 of /webpath/docroot/vendor/twig/twig/src/Loader/ChainLoader.php). – Zeroplexer Jan 23 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.