Drupal 8 包含部分模板 [英] Drupal 8 include part template
问题描述
我正在尝试使用具有自己主题的 Drupal 8,由于我的要求存在很大的结构差异我有一个页面--front.twig.html 和一个 page.twig.html,我想创建模板部件在普通 Symfony2 项目中的 phrozn oder 中使用,例如一个 footer.html.twig 和一个 header.html.twig.这些模板保存在子目录/parts/
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.
例如:
{# in page.html.twig or page--front.html.twig #}
{% include 'parts/footer.html.twig' %}
以字符串形式返回文件名:
Returns the file name as string:
parts/footer.html.twig
Drupal 8 可以做到这一点吗?
It'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' %}
感谢 https://drupal.stackexchange.com/questions/141066/drupal-8-include-part-template
这篇关于Drupal 8 包含部分模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!