2015-11-23 260 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 %}