我正在尝试从文件列表contenttype中获取所有文件的列表,以显示在无序列表中。但是我还没能让文件位置{{ 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>下面这段代码获得了文件名,但它只适用于contenttype文件,而不适用于filelist,因为它是一个数组。
{% 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 %}发布于 2015-11-24 15:36:20
我花了更多的谷歌时间,深入研究了bolt.cms的文档,我发现下面的代码解决了我的问题。这比我想象的要简单得多。希望这对其他人也有帮助。
{% 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.filename }}" title="Download">{{ record.title }}</a></li>
{% endfor %}
{% endif %}https://stackoverflow.com/questions/33866195
复制相似问题