Drupal 8包含零件模板 [英] Drupal 8 include part template

查看:129
本文介绍了Drupal 8包含零件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Drupal 8,拥有自己的主题,由于我的需求有很大的结构差异,我有一个页面 - front.twig.html和一个page.twig.html,我想创建模板部分如在正常的Symfony2项目中的phrozn oder中使用的,例如footer.html.twig和header.html.twig。这些模板保存在子目录/ parts /



但是,我正常地调用这个模板,我只收到一个带有模板名称的字符串。



例如:

  {#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'%} 

感谢 https://drupal.stackexchange.com/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.twig

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' %}

thanks to https://drupal.stackexchange.com/questions/141066/drupal-8-include-part-template

这篇关于Drupal 8包含零件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆