但是,我正常地调用这个模板,我只收到一个带有模板名称的字符串。
例如:
{#in page.html.twig或page - front .html.twig#} {%include'parts / footer.html.twig'%}将文件名作为字符串返回:
parts / footer.html.twig可以使用Drupal 8执行此操作吗?
解决方案可以使用路径中的模板名称
{%include'@ mytheme / parts / footer。 html.twig'%}感谢 drupal.stackexchange/questions/141066/drupal-8-include-part-template
I'm trying to use Drupal 8, with an own theme, due big structure differences for my requirements I have a page--front.twig.html and a page.twig.html, I would like to create template parts as used in phrozn oder in a normal Symfony2 project, for example a footer.html.twig and a header.html.twig. These templates are saved under a subdirectory /parts/
But wenn I call this templates as normal I just receive a string with the name of the template.
For example:
{# in page.html.twig or page--front.html.twig #} {% include 'parts/footer.html.twig' %}Returns the file name as string:
parts/footer.html.twigIt's possible to do that with Drupal 8?
解决方案it's possible using the name of the template in the path
{% include '@mytheme/parts/footer.html.twig' %}thanks to drupal.stackexchange/questions/141066/drupal-8-include-part-template
更多推荐
Drupal 8包含零件模板
发布评论