栏目列表
TanzCMS 官方文档示例,展示模板标签、开放 API、内容管理和部署说明。
栏目页与列表页标签
当前栏目列表
{content model=article catid=$category.id child=1 num=10 pagesize=$category.list_page_size page=$query.page order=updatetime return=t}
<article class="article-item">
<a href="{$t.url}">{$t.title}</a>
<p>{str_cut($t.description,80)}</p>
<span>{$t.published_at_date}</span>
<span>{$t.views} 浏览</span>
</article>
{empty}
<p>暂无内容</p>
{/content}
| 参数 | 说明 |
|---|---|
model=article |
指定内容模型编码。 |
catid=$category.id |
指定当前栏目 ID。 |
child=1 |
包含子栏目内容。 |
num=10 |
最多读取 10 条。 |
pagesize=$category.list_page_size |
每页条数读取栏目设置。 |
page=$query.page |
当前页码来自 URL 参数。 |
order=updatetime |
按更新时间倒序。 |
return=t |
循环变量名。 |
内容变量
| 变量 | 说明 |
|---|---|
{$t.id} |
内容 ID。 |
{$t.title} |
标题。 |
{$t.url} |
详情链接。 |
{$t.thumb} |
缩略图。 |
{$t.description} |
描述。 |
{$t.keywords} |
关键词。 |
{$t.views} |
浏览量。 |
{$t.views_short} |
短格式浏览量。 |
{$t.published_at} |
发布时间完整值。 |
{$t.published_at_date} |
发布日期。 |
{$t.updated_at_date} |
更新日期。 |
{$t.category.name} |
栏目名称。 |
{$t.model.code} |
模型编码。 |
{$t.字段名} |
自定义字段。 |
分页变量
默认 return=t 时:
| 变量 | 说明 |
|---|---|
{$page} |
当前页。 |
{$pagesize} |
每页条数。 |
{$total} |
总记录数。 |
{$nums} |
当前页记录数。 |
{html $pages} |
分页 HTML。 |
{$pagination.has_pages} |
是否有多页。 |
{$pagination.prev_page} |
上一页页码。 |
{$pagination.next_page} |
下一页页码。 |
{$pagination.last_page} |
最后一页页码。 |
如果 return=item,分页变量为 {$page_item}、{html $pages_item}、{$pagination_item.has_pages}。
多列表同页
{content model=article catid=5 num=6 return=news}
<a href="{$news.url}">{$news.title}</a>
{/content}
{content model=article catid=8 num=6 return=download}
<a href="{$download.url}">{$download.title}</a>
{/content}