【发布时间】:2015-11-19 18:31:21
【问题描述】:
我正在尝试逐个字段打印出一个视图,以便我可以将我的样式应用到它并自定义它的外观。
当我复制 views-view-unformatted--MY-TEMPLATE.html.twig 我可以在默认视图中看到这些变量:
{#
/**
* @file
* Default theme implementation to display a view of unformatted rows.
*
* Available variables:
* - title: The title of this group of rows. May be empty.
* - rows: A list of the view's row items.
* - attributes: The row's HTML attributes.
* - content: The row's content.
* - view: The view object.
* - default_row_class: A flag indicating whether default classes should be
* used on rows.
*
* @see template_preprocess_views_view_unformatted()
*
* @ingroup themeable
*/
#}
使用 {{ kint(content) }} 后,我可以看到我有一个 _entity 字段如图所示
但是我不知道如何打印出这些特定字段,甚至无法使用 Kint 找出如何将它们分开。我试过这样做:
{{ kint(content._entity) }}
无济于事,还有很多其他尝试打印出来的方法。
感谢任何帮助!
【问题讨论】:
-
我通过使用不同的视图模板解决了我的问题,但我相信我应该能够做到这一点,所以我会保持这个问题的开放性。
-
你试过 content.entity 吗?