【问题标题】:Create a single template file for the regions in drupal 8为 drupal 8 中的区域创建单个模板文件
【发布时间】:2015-11-28 13:13:36
【问题描述】:

例如,我希望在单个 Twig 文件中包含页脚。

这些是我的地区:

regions:
  nav: Navigation
  content: Content
  content_top: 'Content Top'
  content_bottom: 'Content Bottom'
  front_one: 'Front One'
  front_two: 'Front Two'
  footer: Footer

我尝试在我的主题的模板文件夹中创建一个region--footer.html.twig 文件,但这不起作用。

有什么建议吗?

【问题讨论】:

  • 请更详细地向我们展示您尝试了什么以及出了什么问题/出了什么问题。

标签: php templates drupal twig drupal-8


【解决方案1】:

在drupal 8中摸索新模板后,我成功了:

在我的page.html.twig 最底部:

{% if page.footer %}
  {{ page.footer }}
{% endif %}

然后创建了一个region--footer.html.twig,内容如下:

{% if content %}
      <div{{ attributes }}>
        {{ content }}
      </div>
{% endif %}

我从core/modules/system/templates/region.html.twig得到了这个sn-p

我认为这是在 Drupal 8 中覆盖模板的正确方法

【讨论】:

  • drupal 使用的所有模板都被经典主题覆盖。建议您将其用作基本主题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-01
  • 2018-11-23
相关资源
最近更新 更多