首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bolt cms文件路径文件

bolt cms文件路径文件
EN

Stack Overflow用户
提问于 2015-11-23 16:08:19
回答 1查看 490关注 0票数 1

我正在尝试从文件列表contenttype中获取所有文件的列表,以显示在无序列表中。但是我还没能让文件位置{{ record.file }}工作。我已经通过在{{ record.file }}应该在的地方张贴了{{ record.title }},暂时修复了这个问题。

代码语言:javascript
复制
                        <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,因为它是一个数组。

代码语言:javascript
复制
{% 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 %}
EN

回答 1

Stack Overflow用户

发布于 2015-11-24 15:36:20

我花了更多的谷歌时间,深入研究了bolt.cms的文档,我发现下面的代码解决了我的问题。这比我想象的要简单得多。希望这对其他人也有帮助。

代码语言:javascript
复制
                {% 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 %}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33866195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档