【问题标题】:Drupal 8 print fields inside view twig视图树枝内的 Drupal 8 打印字段
【发布时间】:2017-09-28 12:43:15
【问题描述】:

在名称为“横幅”的内容类型中,我有一个类型为“链接”的字段,其中“机器名称”= field_url_destinazione。

如果我在我的树枝上写这个:

{% if content %}
    {{ content }}
{% endif %}

我看到标题、日期和我的字段“field_url_destinazione”

我只需要显示这个字段,有办法吗?

我试过了:

{{ content.field_url_destinazione }}
{{ fields.field_url_destinazione }}
{{ field.field_url_destinazione }}
{{ field_url_destinazione }}

【问题讨论】:

    标签: drupal twig drupal-8


    【解决方案1】:

    你的第一次尝试

    {{ content.field_url_destinazione }}
    

    应该肯定有效。它可能不起作用的唯一原因是字段名称错误(或树枝模板中的任何其他错误)。


    default node template中所述:

    • 内容:所有节点项。使用 {{ content }} 将它们全部打印出来,或者打印一个子集,例如 {{ content.field_example }}。使用 {{ content|without('field_example') }} 暂时禁止打印给定的子元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多