我有一个视图,其中有一个文件类型字段。所以我将它添加到视图中并为它重写了结果:
<a href="{{ field_documento }}">{{ title }}</a>
以上行产生一个带有 PDF 文档的 href 和节点标题作为标签文本的 a 标签。
现在我已将字段 field_download
替换为字段 field_mdownload
,该字段是对媒体文档类型实体的引用。我无法使用此类字段获得相同的结果。
为此目的,我尝试使用 Twig Twaek 和 Bamboo Twig,并尝试直接访问节点和内容,但它似乎在视图上下文中不起作用。
我尝试使用以下内容:
node.fileld_mdocument.entity.media_file_document.uri.value
node.field_mdocument | file_uri
field_mdocument | file_uri
file_url (field_mdocument)
<% set node = bamboo_load_entity ('node', nid)%>
但这里 twig 似乎无法将 nid 转换为代表节点的整个值。如果我输入 <% set node = bamboo_load_entity ('node', 1)%>
,它会起作用。
有人知道我该如何解决这个问题吗?