Could not find Symfony2 template

I would like to include the template in my opinion, but it does not work, I have this error:

Cannot find template ":: StyleBlock / light-pattern.html.twig" in :: base.html.twig on line 46.

My code is:

{% for zone in content.blocks %} {% set path = '::StyleBlock/' ~ zone.styles %} {% include path %} {% endfor %} 

In detail, I have this message:

InvalidArgumentException: The file "views / StyleBlock / light-pattern.html.twig" does not exist (in: / var / www / gathena / app / Resources).

But the way is right, I do not understand.

I am using Symfony 2.3 and I have a good resolution in my directory

+4
source share
2 answers

You specified the wrong path, it should be:

 {% for zone in content.blocks %} {% set path = 'CmsCmsBundle:StyleBlock:' ~ zone.styles %} {% include path %} {% endfor %} 

as for path src/Cms/CmsBundle/Resources/views/StyleBlock/

The first parameter is your package, the second is the controller in this case StyleBlock , so your views are in your package in the Resources/views/StyleBlock , the last parameter is the name of the template, which is determined by the loop variable in this case, This should be only your name template without any absolute paths. All parameters are divided into :

+7
source

Try the following:

 ::StyleBlock:light-pattern.html.twig 
0
source

Source: https://habr.com/ru/post/1495096/


All Articles