💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# content 内容列表标签 章节导航 - [内容列表标签](#_5) - [格式示例](#_8) - [参数](#_16) - [参数说明](#_38) - [常用示例](#_259) - [字段调用](#_356) ## 内容列表标签 查询模型数据列表、结合分页标签可实现分页、例如获取文章列表等可用该标签。 ## 格式示例 ``` <pre class="calibre16">``` <span class="token5">// 获取模型ID为1的3条数据。</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"3"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` ## 参数 参数名称可选值默认值是否必填支持版本说明catid栏目ID或变量,多个栏目使用英文逗号分隔,必须是同模型v2.2.3.220920+-在列表页可以不填,自动获取。-默认包含下级文章的内容model----模型IDaid---v2.2.3.220920+指定单个文档IDaids文档ID:1,2,3--v2.2.3.220920+指定多个文档ID,英文逗号分隔field-\*-v2.2.3.221215+指定显示的字段,默认是\*表示所有,注意:系统已包含(id,lang,style,views,url,category\_id,status)无需重复指定orderweigh asc,id desc--排序 , 格式为 order="字段名称 desc" 其中desc是倒序,asc是升序num格式为数字、变量、5,1010--限制结果数量; 5,10:第五条开始,获取10条数据where----数据库查询条件page1-- -开启分页,配合 **{hkcms:contentpage /}** 分页标签insub1-包含下级,0-不包含下级1--需要与catid同时使用,默认包含下级文章inlist1-列表模式,0-单页内容0--针对单页,填写catid时,获取catid下级的所有单页,支持分页more1--v2.2.3.220920+不在使用获取副表的数据flag----文档属性值id-$item--指定循环里的变量名,例如id='obj',模板调用如:{$item.title} 变成 {$obj.title}empty----为空的时候输出提示,支持传入htmlcache-3600秒--缓存时间,默认3600秒,对非分页数据有效mod---v2.2.1.20220603+控制隔N行输出的内容等,更多查看下面的示例key---v2.2.1.20220603+指定循环变量,如果没有指定key属性的话,默认使用循环变量$i## 参数说明 `catid` 栏目ID或变量,在列表页时可不填,自动获取列表页的内容数据 1. 获取属于栏目ID为**7**,数量为**6**条的文档 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"7"</span> num<span class="token">=</span><span class="token4">"6"</span><span class="token1">}</span> <span class="token5">// style字段是后台内容管理标题加粗、标题颜色,如果需要那么按以下写法获取</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> style<span class="token">=</span><span class="token4">"{$item.style}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> 封面图:<span class="token"><</span>img src<span class="token">=</span><span class="token4">"{$item.thumb}"</span><span class="token">></span> <span class="token5">// 更多字段可前往后台字段管理里面或手册数据字典里面查看</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 2. 以变量形式获取,例如在列表页有当前栏目变量($Cate),`catid="$Cate.id"` $Cate.id是栏目ID,下面示例为获取当前栏目6条文档并开启分页 ``` <pre class="calibre16">``` <span class="token5">// page="1" 是开启分页</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"$Cate.id"</span> num<span class="token">=</span><span class="token4">"6"</span> page<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>h5<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>h5<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 3. 在列表页,获取当前栏目的文档,可以不传`catid`参数,如下按每页6条分页展示 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content num<span class="token">=</span><span class="token4">"6"</span> page<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>h5<span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span><span class="token">></span><span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>h5<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 4. 同时获取多个栏目ID的文档数据,catid="栏目ID1,栏目id2" 多个栏目ID使用英文逗号分隔开 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"11,12"</span> num<span class="token">=</span><span class="token4">"6"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> style<span class="token">=</span><span class="token4">"{$item.style}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `aid` 获取单条文章,如下获取文档ID为14的记录 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content aid<span class="token">=</span><span class="token4">"14"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> style<span class="token">=</span><span class="token4">"{$item.style}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `aids` 获取多条文章,多个文档使用英文逗号分隔开 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content aids<span class="token">=</span><span class="token4">"14,15"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> style<span class="token">=</span><span class="token4">"{$item.style}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `model`模型ID参数表示按模型id来获取记录,模型ID在模型管理里面可以看到 ``` <pre class="calibre16">``` <span class="token5">// 获取模型id为1的记录,num控制显示数量</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"5"</span><span class="token1">}</span> 文档标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> 文档描述:<span class="token1">{</span>$item<span class="token1">.</span>description<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `order` 用于字段排序,格式为order="字段名 asc,字段名2 desc",其中`asc` 表示升序 `desc` 表示倒序,多个排序字段使用逗号分隔开 ``` <pre class="calibre16">``` <span class="token5">// 列表页,按最新发布的靠前排序</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content order<span class="token">=</span><span class="token4">"publish_time desc"</span><span class="token1">}</span> 文档标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> 文档描述:<span class="token1">{</span>$item<span class="token1">.</span>description<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `num` 用于控制记录条数,`num="5"` 表示只获取5条记录。也可以控制从第几条开始,5,10表示第5~15条记录。**注意5,10格式不能用于分页上** ``` <pre class="calibre16">``` 注意这种限制范围方式不得用于分页 <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"5,10"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 1. 动态控制每页展示文档条数可以在后台栏目管理里面配置(栏目管理-》添加-》更多-》分页大小) ![](https://img.kancloud.cn/83/1d/831d044ca1a66ff001694420cf6c3177_631x89.png) 动态文档条数写法示例,num="$Cate.num",$Cate.num是当前栏目的分页大小 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content num<span class="token">=</span><span class="token4">"$Cate.num"</span> page<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token5">// style字段是后台可设置加粗与颜色</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> style<span class="token">=</span><span class="token4">"{$item.style}"</span><span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `where` 数据库查询条件,语法跟SQL where基本相同。格式:where="字段名 = 1" ,支持传入变量 ``` <pre class="calibre16">``` <span class="token1">{</span><span class="token5">// 获取模型id为1的记录,where条件意思是只显示阅读量大于1的记录}</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> where<span class="token">=</span><span class="token4">"views > 1"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> 描述:<span class="token1">{</span>$item<span class="token1">.</span>description<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` **sql语法可参考:[https://www.w3school.com.cn/sql/sql\_where.asp](https://www.w3school.com.cn/sql/sql_where.asp)** **更多查询表达式参考:[https://www.kancloud.cn/manual/thinkphp6\_0/1037537](https://www.kancloud.cn/manual/thinkphp6_0/1037537)** `page` 开启分页功能,默认是没有分页的,开启后配合`contentpage分页标签`来实现生成底部下的页码 ``` <pre class="calibre16">``` <span class="token1">{</span><span class="token5">// page="1" 开启分页}</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> page<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `insub` 控制是否显示下级,该属性需要结合`catid`来使用,默认自动包含该栏目下的所有文档数据包含子级,值为1-包含下级,0-不包含下级。 ``` <pre class="calibre16">``` <span class="token5">// 不包括子级下的文档,注意获取的下级是跟当前栏目模型一致</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> insub<span class="token">=</span><span class="token4">"0"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` > 注意:获取下级栏目的文档是跟caitid里面的栏目ID模型一致 `inlist` 列表模式用于获取多条单页模型的文章。例如catid="1"栏目ID为1是单页栏目,那么默认情况下获取的是一条单页内容,获取该单页下所有单页栏目里的文档则可以使用该参数。示例如下: ``` <pre class="calibre16">``` 开启列表模式,获取当前栏目下<span class="token3">5</span>条单页列表 <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> inlist<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"5"</span><span class="token1">}</span> <span class="token"><</span>div<span class="token">></span> <span class="token1">{</span>hkcms<span class="token1">:</span>raw name<span class="token">=</span><span class="token4">"$item['content']"</span> <span class="token">/</span><span class="token1">}</span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `more`用于开启列表页获取副表字段。模型管理里面字段管理可以看到字段是否是主表还是副表,**后续版本默认有副表字段无需手动开启** ``` <pre class="calibre16">``` 开启副表访问 <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> more<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"5"</span><span class="token1">}</span> 副表内容:<span class="token1">{</span>$item<span class="token1">.</span>content<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `flag` 用于输出特定的文档属性,例如在文档属性里面新增了hot属性,那么写法如下 ``` <pre class="calibre16">``` 输出模型ID为<span class="token3">1</span>且文章带有hot属性的记录 <span class="token1">{</span>hkcms<span class="token1">:</span>content flag<span class="token">=</span><span class="token4">"hot"</span> model<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"5"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` flag属性里面填写的是下面图片中的属性值 ![](https://img.kancloud.cn/2c/2c/2c2c2437caffcdf015cbf0f1c9f9316e_747x264.png) 1. flag属性多个使用:and 或 or 关键字,例如获取同时拥有`最新(new)`和`热门推荐(hot)`的属性文档 ``` <pre class="calibre16">``` <span class="token5">// and 是同时满足,注意两边的空格</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> flag<span class="token">=</span><span class="token4">"new and hot"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br<span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 2. 获取拥有`最新(new)`或者有`热门推荐(hot)`的属性文档 ``` <pre class="calibre16">``` <span class="token5">// or 只需要包含其中一个属性即可,注意两边的空格,多个写法:flag="new or top or top" 以此类推</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> flag<span class="token">=</span><span class="token4">"new or top"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br<span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `id` 用于改变循环变量默认是`$item`,例如改成$vo则写成id="vo"无需加$。常用于多个标签嵌套时使用循环变量而不受影响 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> id<span class="token">=</span><span class="token4">"vo"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$vo<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br <span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `empty`为空(没有数据)提示标签,不支持传入HTML,但可以传入变量形式使用html 1. 示例如下:栏目id为111,里面没有文档时页面上显示`文档内容不存在` ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"111"</span> empty<span class="token">=</span><span class="token4">"文档内容不存在"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br <span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 2. 传入变量的形式插入html标签 ``` <pre class="calibre16">``` <span class="token1">{</span>php<span class="token1">}</span>$empty <span class="token">=</span> <span class="token4">'<p align="center">- 没有更多数据了 -</p>'</span><span class="token1">;</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"111"</span> empty<span class="token">=</span><span class="token4">"$empty"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br <span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `cache` 设置缓存时间,默认是3600秒 ``` <pre class="calibre16">``` <span class="token5">// 设置7200秒</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> cache<span class="token">=</span><span class="token4">"7200"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br <span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `mod`属性用于每隔N行输出的内容,例如控制N条记录的换行、或增加hr等,例如下面的例子每输出5个栏目增加一个下划线标签 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> mod<span class="token">=</span><span class="token4">"5"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span>br<span class="token">/</span><span class="token">></span> <span class="token1">{</span><span class="token2">if</span> $mod<span class="token">==</span><span class="token3">5</span><span class="token1">}</span> <span class="token5">// 启用mod后,会有$mod变量</span> <span class="token"><</span>hr<span class="token">></span> <span class="token1">{</span><span class="token">/</span><span class="token2">if</span><span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 1. 输出奇数偶数记录,例如:mod="2",标签内会有$mod变量,里面的值每次计算到2的时候重新计数例如(1,2 | 1,2 | 1,2) ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> mod<span class="token">=</span><span class="token4">"2"</span><span class="token1">}</span> <span class="token1">{</span><span class="token2">if</span> $mod<span class="token">==</span><span class="token3">2</span><span class="token1">}</span> 偶数:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> <span class="token1">{</span><span class="token2">else</span> <span class="token">/</span><span class="token1">}</span> 奇数:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> <span class="token1">{</span><span class="token">/</span><span class="token2">if</span><span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` `key`参数用于指定循环`$i`的变量,只有标签嵌套时可能需要重新命名$key ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span><span class="token1">}</span> <span class="token5">// $i 是从1开始的。</span> <span class="token"><</span>p<span class="token">></span>序号:第<span class="token1">{</span>$i<span class="token1">}</span>篇文档 <span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 改变$i的名称 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"9"</span> key<span class="token">=</span><span class="token4">"ii"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>序号:第<span class="token1">{</span>$ii<span class="token1">}</span>篇文档 <span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` ## 常用示例 - 获取栏目ID为1的列表 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>计数变量:$i,从<span class="token3">1</span>开始:第<span class="token1">{</span>$i<span class="token1">}</span>篇<span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>数组索引:<span class="token1">{</span>$key<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>URL:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> <span class="token5">// 传入变量的形式</span> <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"$Cate.id"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>URL:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` - 根据模型ID获取 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>循环变量,从<span class="token3">1</span>开始:<span class="token1">{</span>$i<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>数组索引值:<span class="token1">{</span>$key<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>URL:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>作者:<span class="token1">{</span>$item<span class="token1">.</span>author<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>关键字:<span class="token1">{</span>$item<span class="token1">.</span>keywords<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` - 只获取6条数据 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"6"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>循环变量,从<span class="token3">1</span>开始:<span class="token1">{</span>$i<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>数组索引值:<span class="token1">{</span>$key<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>URL:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>作者:<span class="token1">{</span>$item<span class="token1">.</span>author<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>关键字:<span class="token1">{</span>$item<span class="token1">.</span>keywords<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` 获取文章的分类信息与模型信息 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content model<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>URL:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>div<span class="token">></span>栏目名称:<span class="token1">{</span>$item<span class="token1">.</span>category<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div<span class="token">></span>栏目英文:<span class="token1">{</span>$item<span class="token1">.</span>category<span class="token1">.</span>name<span class="token1">}</span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div<span class="token">></span>模型名称:<span class="token1">{</span>$item<span class="token1">.</span>model<span class="token1">.</span>name<span class="token1">}</span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div<span class="token">></span>模型类型:<span class="token1">{</span>$item<span class="token1">.</span>model<span class="token1">.</span>type<span class="token1">}</span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` - 获取副表信息、后续版本默认包含 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> more<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>封面:<span class="token1">{</span>$item<span class="token1">.</span>thumb<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token"><</span>p<span class="token">></span>浏览量:<span class="token1">{</span>$item<span class="token1">.</span>views<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` - 获取包含栏目子级的列表数据 ``` <pre class="calibre16">``` 注:默认是包含的,如果不想包含 insub<span class="token">=</span><span class="token4">"0"</span> 即可 <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> insub<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` - 数据分页 开启分页,每页只显示2条记录 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content catid<span class="token">=</span><span class="token4">"1"</span> page<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"2"</span><span class="token1">}</span> <span class="token"><</span>p<span class="token">></span>标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span><span class="token"><</span><span class="token">/</span>p<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> <span class="token"><</span>div<span class="token">></span> <span class="token5">//配合分页标签</span> <span class="token1">{</span>hkcms<span class="token1">:</span>contentpage item<span class="token">=</span><span class="token4">"home,pre,pageno,next,last,info,jump"</span> <span class="token">/</span><span class="token1">}</span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` - 文档属性 flag="top and new"表示只查出同时满足top和new属性值,flags="top or new"表示只要查出有top或new属性值,注意and和or两边的空格 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>content num<span class="token">=</span><span class="token4">"6"</span> page<span class="token">=</span><span class="token4">"1"</span> flag<span class="token">=</span><span class="token4">"top or ceshi"</span><span class="token1">}</span> 标题:<span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> 循环文档属性<span class="token1">(</span>包含所有属性字段<span class="token1">)</span>: <span class="token1">{</span>hkcms<span class="token1">:</span>volist name<span class="token">=</span><span class="token4">"item.flags"</span> id<span class="token">=</span><span class="token4">"vo"</span><span class="token1">}</span> <span class="token"><</span>span<span class="token">></span><span class="token1">{</span>$vo<span class="token1">[</span><span class="token4">'title'</span><span class="token1">]</span><span class="token1">}</span><span class="token"><</span><span class="token">/</span>span<span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>volist<span class="token1">}</span> 原始值:<span class="token1">{</span>$item<span class="token1">.</span>flags_raw<span class="token1">}</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>content<span class="token1">}</span> ``` ``` ## 字段调用 更多字段可在模型管理》字段管理里面找到字段的名字,以下仅包含主要的字段 **注意:其中`$item`变量根据content标签的id参数影响,默认是:$item。$Info 是详情页固定调用方式** 字段名说明调用方式详情页id文档ID{$[item.id](http://item.id)}{$[Info.id](http://Info.id)}category\_id文档所属栏目ID{$item.category\_id}{$Info.category\_id}category\_ids文档所属父栏目ID,例如:1,2,3 逗号分隔开{$item.category\_ids}{$Info.category\_ids}model\_id文档所属模型ID{$item.model\_id}{$Info.model\_id}flags文档属性,数组,使用volist标签循环{$item.flags}{$Info.flags}- title使用volist循环后,里面写{$item.title},文档属性标题--- name文档属性标题--flags\_raw文档属性,多个属性逗号分隔,例如:top,new{$item.flags\_raw}{$Info.flags\_raw}lang语言标识{$item.lang}{$Info.lang}publish\_time发布时间,格式是秒,使用date日期格式化标签,或使用下方的字段{$item.publish\_time}{$Info.publish\_time}publish\_time\_text发布时间,格式是年月日时分秒{$item.publish\_time\_text}{$Info.publish\_time\_text}fullurl包含完整域名的URL{$item.fullurl}{$Info.fullurl}