2015-11-23 249 views
0

我试图从一个文件列表contenttype中显示在无序列表中的所有文件的列表。但我一直无法获得文件位置{{ record.file }}的工作。我通过发布{{ record.title }}来临时解决这个问题,其中{{ record.file }}应该是。下面螺栓cms文件路径文件

     <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文件,而不是文件清单,因为它是一个数组。

{% 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 %} 

回答

1

我花了一些更多的谷歌的时间,并通过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 %}