【发布时间】:2015-11-23 08:08:19
【问题描述】:
我正在尝试从文件列表内容类型中获取所有文件的列表以显示在无序列表中。但我无法让文件位置{{ record.file }} 工作。我已经通过在{{ record.file }} 应该在的位置发布{{ record.title }} 临时解决了这个问题。
<ul>
{% set filerecord = record.file() %}
{% if record.file is not empty %}
{% for record in filerecord %}
<li><i class="fa fa-file-pdf-o"></i><a href="{{ paths.files }}{{ record.file }}" title="Download">{{ record.title }}</a></li>
{% endfor %}
{% endif %}
</ul>
下面的这段代码确实获取了文件名,但仅适用于内容类型文件,而不适用于文件列表,因为它是一个数组。
{% for key,value in record.values if key in ['templatefields'] %}
<span><i class="fa fa-calendar"></i>Oplevering |</span>
<span>{{ record.starts_at }} /</span>
<span>{{ record.ends_at }} |</span>
{% set filerecord = record.file() %}
{% if filerecord is not empty %}<span><i class="fa fa-file-pdf-o"></i><a href="{{ paths.files }}{{ record.file }}" title="Download de folder">Download de folder</a></span>{% endif %}
{% endfor %}
【问题讨论】:
标签: file templates twig bolt-cms