【问题标题】:bolt cms file paths filebolt cms 文件路径文件
【发布时间】: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


    【解决方案1】:

    我花了更多时间在 Google 上搜索并仔细研究了 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 %}
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      • 2018-09-29
      • 2017-06-14
      • 1970-01-01
      • 2020-08-29
      相关资源
      最近更新 更多