Drupal 8包含零件模板

编程入门 行业动态 更新时间:2024-10-24 08:30:07
本文介绍了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'%}

感谢 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.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 drupal.stackexchange/questions/141066/drupal-8-include-part-template

更多推荐

Drupal 8包含零件模板

本文发布于:2023-11-23 01:20:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619596.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:零件   模板   Drupal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!