說明:用于獲取指定Tag的文檔列表
使用方法:{% tagDataList 變量名稱 with tagId="1" %}
如將變量定義為 archives {% tagDataList archives with tagId="1" %}...{% endtagDataList %}
tagDataList
支持的參數(shù)有:TagID tagId
tagId
可以獲取指定Tag的文檔列表如 tagId="1"
獲取TagID為1的文檔列表。
> 如果未指定 tagId
它會嘗試讀取當(dāng)前Tag頁面的TagID。
模型ID moduleId
moduleId
可以獲取指定文檔模型的文檔列表如 moduleId="1"
獲取文章模型的文檔列表。
排序方式 order
order
可以指定文檔顯示的排序規(guī)則,支持依據(jù) 最新文檔排序 order="id desc"
、瀏覽量最多文檔排序 order="views desc"
、按后臺自定義排序 order="sort desc"
,默認(rèn)按照自定義排序,可以不用填。
顯示數(shù)量 limit
limit
可以指定顯示數(shù)量,按多少數(shù)量來分頁,比如limit="10"
則只會顯示10條。,limit
在不是分頁列表的時(shí)候,支持offset
模式,也就是 ,
分隔模式,如想從第2條開始,獲取10條數(shù)據(jù),可以設(shè)置成 limit="2,10"
。
列表類型 type
type
支持按 page、list 方式列出。默認(rèn)值為list,type="list"
時(shí),只會顯示 指定的 limit 指定的數(shù)量,如果type="page"
后續(xù)可用 pagination
來組織分頁顯示 {% pagination pages with show="5" %}
。
分頁標(biāo)簽 pagination
pagination
來組織分頁顯示 {% pagination pages with show="5" %}
。
站點(diǎn)ID siteId
siteId
一般不需要填寫,如果你使用后臺的多站點(diǎn)管理創(chuàng)建了多個(gè)站點(diǎn),并且想調(diào)用其他站點(diǎn)的數(shù)據(jù),則可以通過指定 siteId
來實(shí)現(xiàn)調(diào)用指定站點(diǎn)的數(shù)據(jù)。
archives 是一個(gè)數(shù)組對象,因此需要使用 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")}}
{# page 分頁列表展示 #}
<div>
{% tagDataList archives with type="page" 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 %}
{% endtagDataList %}
{# 分頁代碼 #}
<div>
{% pagination pages with show="5" %}
{# 首頁 #}
<a class="{% if pages.FirstPage.IsCurrent %}active{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
{# 上一頁 #}
{% if pages.PrevPage %}
<a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
{% endif %}
{# 中間多頁 #}
{% for item in pages.Pages %}
<a class="{% if item.IsCurrent %}active{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
{% endfor %}
{# 下一頁 #}
{% if pages.NextPage %}
<a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
{% endif %}
{# 尾頁 #}
<a class="{% if pages.LastPage.IsCurrent %}active{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
{% endpagination %}
</div>
</div>