说明:用于获取指定Tag的文档列表
使用方法:{% tagDataList 变量名称 with tagId="1" %}
如将变量定义为 archives {% tagDataList archives with tagId="1" %}...{% endtagDataList %}
如果未指定 tagId 它会尝试读取当前Tag页面的TagID。
order
order
可以指定文档显示的排序规则,支持依据 最新文档排序 order="id desc"
、浏览量最多文档排序 order="views desc"
。limit
limit
可以指定显示数量,按多少数量来分页,比如limit="10"
则只会显示10条。,limit
在不是分页列表的时候,支持offset
模式,也就是 ,
分隔模式,如想从第2条开始,获取10条数据,可以设置成 limit="2,10"
。type
支持按 page、list、related 方式列出。默认值为list,type="list"
时,只会显示 指定的 limit 指定的数量,如果type="page"
后续可用pagination
pagination
来组织分页显示 {% pagination pages with show="5" %}
。archives 是一个数组对象,因此需要使用 for
循环来输出
Id
Title
Link
Keywords
Description
CategoryId
Views
Images
Logo
Thumb
CommentCount
CreatedTime
时间戳,需要使用格式化时间戳为日期格式 {{stampToDate(item.CreatedTime, "2006-01-02")}}
UpdatedTime
时间戳,需要使用格式化时间戳为日期格式 {{stampToDate(item.UpdatedTime, "2006-01-02 15:04:05")}}
{# page 分页列表展示 #}
<div>
{% tagDataList archives with type="page" limit="10" %}
{% for item in archives %}
<li class="item layui-flex">
<a href="{{item.Link}}" class="link flex-item">
<h5 class="title">{{item.Title}}</h5>
<div class="description">{{item.Description}}</div>
<div class="meta">
<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}}" class="thumb">
<img class="thumb-image" alt="{{item.Title}}" src="{{item.Thumb}}">
</a>
{% endif %}
</li>
{% empty %}
<li class="item empty">
该列表没有任何内容
</li>
{% endfor %}
{% endtagDataList %}
{# 分页代码 #}
<div class="layui-box layui-laypage layui-laypage-default">
{% pagination pages with show="5" %}
{# 首页 #}
<a class="layui-laypage-first {% if pages.FirstPage.IsCurrent %}layui-laypage-curr{% endif %}" href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
{# 上一页 #}
{% if pages.PrevPage %}
<a class="layui-laypage-prev" href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
{% endif %}
{# 中间多页 #}
{% for item in pages.Pages %}
<a class="{% if item.IsCurrent %}layui-laypage-curr{% endif %}" href="{{item.Link}}">{{item.Name}}</a>
{% endfor %}
{# 下一页 #}
{% if pages.NextPage %}
<a class="layui-laypage-next" href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
{% endif %}
{# 尾页 #}
<a class="layui-laypage-last {% if pages.LastPage.IsCurrent %}layui-laypage-curr{% endif %}" href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
{% endpagination %}
</div>
</div>