說明:獲取當(dāng)前文檔的相關(guān)文檔。相關(guān)文檔的邏輯是:根據(jù)當(dāng)前文檔的文檔id,獲取同分類的臨近文檔。因此該標(biāo)簽只能在文檔詳情頁(yè)使用。
使用方法:{% archiveList 變量名稱 with type="related" limit="10" %}
如將變量定義為 archives {% archiveList archives with type="related" limit="10" %}...{% endarchiveList %}
type
的值為 related 的情況下,不支持 order 參數(shù)。
type
的值為 related 的情況下,支持 like 參數(shù)。 like=“keywords|relation”,默認(rèn)不需要 like 參數(shù),它自動(dòng)獲取最靠近當(dāng)前文檔的其他文檔。如果指定了 like=“keywords”,則會(huì)根據(jù)文檔第一個(gè)關(guān)鍵詞來獲取相關(guān)的文檔。如果指定了 like=“relation”,則只會(huì)展示后臺(tái)文檔編輯界面設(shè)置的相關(guān)文檔。
archives 是一個(gè)數(shù)組對(duì)象,因此需要使用 for
循環(huán)來輸出
Id
Title
Link
Keywords
Description
CategoryId
Views
Images
Logo
Thumb
CommentCount
CreatedTime
時(shí)間戳,需要使用格式化時(shí)間戳為日期格式 {{stampToDate(item.CreatedTime, "2006-01-02")}}
UpdatedTime
時(shí)間戳,需要使用格式化時(shí)間戳為日期格式 {{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
獲取相關(guān)文檔標(biāo)簽,只能在文檔詳情頁(yè)使用。
{# related 相關(guān)文檔列表展示 #}
<div>
{% archiveList archives with type="related" limit="10" %}
{% for item in archives %}
<li>
<a href="{{item.Link}}">
<h5>{{item.Title}}</h5>
<div>{{item.Description}}</div>
<div>
<span>{% categoryDetail with name="Title" id=item.CategoryId %}</span>
<span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
<span>{{item.Views}} 閱讀</span>
</div>
</a>
{% if item.Thumb %}
<a href="{{item.Link}}">
<img alt="{{item.Title}}" src="{{item.Thumb}}">
</a>
{% endif %}
</li>
{% empty %}
<li>
該列表沒有任何內(nèi)容
</li>
{% endfor %}
{% endarchiveList %}
</div>