# channel 栏目标签
- [栏目标签](#_2)
- [格式示例](#_4)
- [参数](#_20)
- [参数说明](#_39)
- [示例](#_227)
- [数据字典](#_284)
## 栏目标签
用于调用栏目管理的数据
## 格式示例
```
<pre class="calibre16">```
<span class="token5">// 获取顶级菜单栏目</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> where<span class="token">=</span><span class="token4">"ismenu=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>channel<span class="token1">}</span>
```
```
> 2.1.220504\_202205201800版本起,新增ismenu属性,如下
```
<pre class="calibre16">```
<span class="token5">// 获取顶级菜单栏目、显示导航栏目菜单</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<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>channel<span class="token1">}</span>
```
```
## 参数
参数名称可选值默认值是否必填支持版本说明name栏目ID或变量-type值为peer或son时必填-栏目ID,可以传入变量或指定ID,2.2.3.220920版本起支持多个id,详情见下面参数说明typeson
peer
top---指定获取的栏目层级
son-获取下级栏目
peer-表示同级栏目
top-表示顶级栏目num例子:
10
或者
10,12---限制结果数量
例如:
10 : 表示获取10条
10,12 : 表从第10开始的12条记录model模型表ID---指定模型IDwhere----数据库查询条件order-weigh desc--排序方式, 格式为 order="字段名称 desc" 其中desc是倒序,asc是升序id-$item--指定循环里的变量名,例如id='obj',模板调用如:{$item.title} 变成 {$obj.title}empty----为空的时候输出提示,支持传入htmlcurrentstyle-active--css class 类名,用于定义当前选中状态样式cache-3600秒--缓存时间,默认3600秒istotal1---统计文档数量ismenu1-->=v2.1.220504显示导航栏目菜单lang--->=v2.2.1.20220603多语言情况下获取指定语言的栏目mod--->=v2.2.1.20220603调用:{$mod}
用于控制偶数输出、换行等,更多查看下面的示例key--->=v2.2.1.20220603指定循环值变量名,默认为$i,从1开始计数每循环一次+1## 参数说明
- `name` 参数通常用于查单条特定的栏目数据。如果type值为peer或son时该值必填,支持变量或数字id
获取栏目ID为3的记录```
<pre class="calibre20">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"3"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
根据变量来获取栏目,假设在内容详情页有`$Info`变量,$[Info.categroy.id](http://Info.categroy.id) 是当前文章所属ID,那么我们可以通过这个id来获取栏目同级的栏目代码如下:
```
<pre class="calibre16">```
<span class="token5">// 同级</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"$Info.category.id"</span> type<span class="token">=</span><span class="token4">"peer"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
或者使用变量可以获取当前栏目的上级栏目信息
```
<pre class="calibre16">```
<span class="token5">// $Cate 是当前 栏目的信息该变量在栏目首页、列表页、详情页、单页都存在</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"$Cate.parent_id"</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>channel<span class="token1">}</span>
```
```
2.2.3.220920版本起支持多个id获取栏目。如下,多个栏目ID逗号分隔开
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"1,3,7"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `type`属性用于获取的栏目层级,如下
1.`son` 获取下级栏目,需要结合name使用
```
<pre class="calibre16">```
<span class="token5">// 获取栏目ID为1的所有下级菜单</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"1"</span> type<span class="token">=</span><span class="token4">"son"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
2.`peer` 表示同级栏目,需要结合name使用
```
<pre class="calibre16">```
<span class="token5">// 获取栏目ID为1的所有同级菜单</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"1"</span> type<span class="token">=</span><span class="token4">"peer"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
3.`top` 表示顶级栏目
```
<pre class="calibre16">```
<span class="token5">// 获取顶级菜单</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<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="token"><</span>br<span class="token">></span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `num` 限制结果数量。例如获取10条栏目那么num="10",当然也支持从第几条开始,例如num="4,2" 表示从第4条获取两条那就是第4条、第五条。
```
<pre class="calibre16">```
<span class="token5">// 获取顶级栏目从第二条开始获取两条</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<span class="token">=</span><span class="token4">"1"</span> num<span class="token">=</span><span class="token4">"2,3"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `model`模型id,模型ID在模型管理里面可以看到
```
<pre class="calibre16">```
<span class="token5">// 获取模型id=1的所有栏目</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel model<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="token"><</span>br<span class="token">></span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
```
<pre class="calibre16">```
<span class="token5">// 使用变量的形式获取顶级栏目</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel model<span class="token">=</span><span class="token4">"$Info.model_id"</span> type<span class="token">=</span><span class="token4">"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="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<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)**
- `order` 用于字段排序例如上面的代码,格式为order="字段名 asc,字段名2 desc",其中`asc` 表示正序 `desc` 表示倒序,多个排序字段使用逗号分隔开
```
<pre class="calibre16">```
<span class="token5">// 多个字段排序使用逗号分隔开</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"21"</span> type<span class="token">=</span><span class="token4">"son"</span> order<span class="token">=</span><span class="token4">"weigh asc"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `id` 用于改变循环变量默认是$item,例如改成$vo则写成id="vo"无需加$。常用于多个标签嵌套时使用循环变量而不受影响
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"21"</span> type<span class="token">=</span><span class="token4">"son"</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="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `empty`为空提示标签,不支持传入HTML,但可以传入变量
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"111"</span> type<span class="token">=</span><span class="token4">"son"</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="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
传入变量的形式使用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>channel name<span class="token">=</span><span class="token4">"111"</span> type<span class="token">=</span><span class="token4">"son"</span> empty<span class="token">=</span><span class="token4">"$empty"</span><span class="token1">}</span>
<span class="token1">{</span>php<span class="token1">}</span><span class="token6">dump</span><span class="token1">(</span>$item<span class="token1">)</span><span class="token1">{</span><span class="token">/</span>php<span class="token1">}</span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `currentstyle` 当前选中栏目的class样式用于字体高亮等自定义样式、值默认是active
```
<pre class="calibre16">```
<span class="token5">// currentstyle 默认是active,你可以在这指定其他的class</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<span class="token">=</span><span class="token4">"1"</span> currentstyle<span class="token">=</span><span class="token4">"active"</span><span class="token1">}</span>
<span class="token5">// 例如:如果当前是新闻中心栏目那么只有新闻中心栏目这条记录有 active 类</span>
<span class="token"><</span>li class<span class="token">=</span><span class="token4">"nav-item dropdown {$item.currentstyle}"</span><span class="token">></span>
<span class="token"><</span>a class<span class="token">=</span><span class="token4">"nav-link dropdown-toggle"</span> href<span class="token">=</span><span class="token4">"{$item.url}"</span> target<span class="token">=</span><span class="token4">"{$item.target}"</span><span class="token">></span><span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span>i class<span class="token">=</span><span class="token4">"fa fa-angle-down"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span>
<span class="token"><</span><span class="token">/</span>li<span class="token">></span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `cache` 设置缓存时间单位是秒,系统默认缓存是3600秒,设置成一天:cache="86400"
- `istotal` 开启文档数量统计,istotal="1"开启
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"9"</span> type<span class="token">=</span><span class="token4">"son"</span> istotal<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="token"><</span>br<span class="token">></span>
数量:<span class="token1">{</span>$item<span class="token1">.</span>total<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `ismenu` 显示导航菜单,值为ismenu="1"。在后台栏目管理页面可以控制导航菜单的显示。
```
<pre class="calibre16">```
<span class="token5">// 获取顶级菜单栏目</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<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>channel<span class="token1">}</span>
```
```
- `lang` 指定获取特定语言的栏目,需要开启内容多语言才有效
```
<pre class="calibre16">```
<span class="token5">// lang="en" 只获取英文不管语言怎么切换都是英文</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"9"</span> lang<span class="token">=</span><span class="token4">"en"</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>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- `mod`属性用于控制一定记录的换行、或增加hr或奇数偶数等标签处理,例如下面的例子每输出5个栏目增加个hr标签
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> mod<span class="token">=</span><span class="token4">"5"</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>br<span class="token">></span><span class="token"><</span><span class="token">/</span>p<span class="token">></span>
<span class="token5">// $mod的值是从1开始的</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="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>channel<span class="token1">}</span>
```
```
mod输出奇数偶数记录,设mod="2",标签内会有$mod变量,里面的值每次计算到2的时候重新计数例如(1,2,1,2,1,2)
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</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>channel<span class="token1">}</span>
```
```
- `key`参数用于指定循环$i的变量,只有标签嵌套时可能需要重新命名$key
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</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>br<span class="token">></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>br<span class="token">></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>channel<span class="token1">}</span>
```
```
更改循环变量示例
```
<pre class="calibre16">```
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> key<span class="token">=</span><span class="token4">"ii"</span><span class="token1">}</span>
<span class="token5">// key="j" 表示这个标签的循环值是{$j},这样就可以避免嵌套的标签依然可以获取外层的标签$ii变量。</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"$item['id']"</span> id<span class="token">=</span><span class="token4">"son"</span> type<span class="token">=</span><span class="token4">"son"</span> key<span class="token">=</span><span class="token4">"j"</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>br<span class="token">></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>$j<span class="token1">}</span> <span class="token"><</span>br<span class="token">></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>$son<span class="token1">.</span>title<span class="token1">}</span> <span class="token"><</span>br<span class="token">></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>channel<span class="token1">}</span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
## 示例
- 多级嵌套获取导航栏的栏目数据
```
<pre class="calibre16">```
<span class="token5">// type = top, 获取的是顶级栏目。ismenu=1获取导航,在栏目管理里面可以控制导航显示</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span>
<span class="token5">// $item 默认的循环变量名,{if}{/if}这是if语句,下面是判断是不是有下级,有下级就显示下拉列表。</span>
<span class="token"><</span>li class<span class="token">=</span><span class="token4">"{$item.currentstyle} nav-item {if $item.has_child}dropdown{/if}"</span><span class="token">></span>
<span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> target<span class="token">=</span><span class="token4">"{$item.target}"</span> class<span class="token">=</span><span class="token4">"nav-link"</span> title<span class="token">=</span><span class="token4">"{$item.title}"</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="token2">if</span> $item<span class="token1">.</span>has_child<span class="token1">}</span>
<span class="token"><</span>ul class<span class="token">=</span><span class="token4">"dropdown-menu mt-0"</span><span class="token">></span>
<span class="token5">// 获取下级栏目,id="son"表示里面的循环变量由默认的$item变成$son,在标签嵌套中这样使用不会影响上级的$item变量</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"$item['id']"</span> id<span class="token">=</span><span class="token4">"son"</span> type<span class="token">=</span><span class="token4">"son"</span> ismenu<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span>
<span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$son.url}"</span> class<span class="token">=</span><span class="token4">"dropdown-item {$son.currentstyle} "</span> title<span class="token">=</span><span class="token4">"{$son.title}"</span><span class="token">></span><span class="token1">{</span>$son<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>channel<span class="token1">}</span>
<span class="token"><</span><span class="token">/</span>ul<span class="token">></span>
<span class="token1">{</span><span class="token">/</span><span class="token2">if</span><span class="token1">}</span>
<span class="token"><</span><span class="token">/</span>li<span class="token">></span>
<span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>channel<span class="token1">}</span>
```
```
- 获取同级栏目示例
```
<pre class="calibre16">```
<span class="token5">// $Cate是当前栏目的数据,该变量在列表页、内容页、栏目首页模板存在</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"$Cate.id"</span> type<span class="token">=</span><span class="token4">"peer"</span> ismenu<span class="token">=</span><span class="token4">"1"</span> currentstyle<span class="token">=</span><span class="token4">"btn-primary"</span><span class="token1">}</span>
<span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> class<span class="token">=</span><span class="token4">"btn {$item.currentstyle}"</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>channel<span class="token1">}</span>
```
```
- 获取指定栏目、以及不存在时显示:暂无数据
```
<pre class="calibre16">```
<span class="token1">{</span><span class="token5">//获取单条栏目信息}</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"9"</span> empty<span class="token">=</span><span class="token4">"暂无数据"</span><span class="token1">}</span>
<span class="token"><</span>h1 class<span class="token">=</span><span class="token4">"title"</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>h1<span class="token">></span>
<span class="token"><</span>p class<span class="token">=</span><span class="token4">"lead"</span><span class="token">></span>栏目描述:<span class="token1">{</span>$item<span class="token1">.</span>seo_desc<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>channel<span class="token1">}</span>
```
```
- currentstyle示例:获取当前栏目高亮
效果如下
![](https://img.kancloud.cn/76/0f/760fb03666840184c63484b07a573cfc_233x225.png)
表示当前栏目是行业资讯,注意:你需要写好定义好class样式。代码示例
```
<pre class="calibre16">```
<span class="token5">// 显示高亮的class,默认是active</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel type<span class="token">=</span><span class="token4">"top"</span> ismenu<span class="token">=</span><span class="token4">"1"</span> currentstyle<span class="token">=</span><span class="token4">"active"</span> <span class="token1">}</span>
<span class="token5">// 只需要在class里面写上{$item.currentstyle},如果是当前栏目会有class="active"</span>
<span class="token"><</span>a class<span class="token">=</span><span class="token4">"{$item.currentstyle}"</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>channel<span class="token1">}</span>
```
```
- 排序与统计文档数量
```
<pre class="calibre16">```
<span class="token5">// 排序 desc-倒序,asc-升序。istotal=1 开启统计文档数量</span>
<span class="token1">{</span>hkcms<span class="token1">:</span>channel name<span class="token">=</span><span class="token4">"10"</span> type<span class="token">=</span><span class="token4">"son"</span> cache<span class="token">=</span><span class="token4">"7200"</span> order<span class="token">=</span><span class="token4">"update_time desc"</span> istotal<span class="token">=</span><span class="token4">"1"</span><span class="token1">}</span>
<span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> class<span class="token">=</span><span class="token4">"btn {$item.currentstyle}"</span><span class="token">></span><span class="token1">{</span>$item<span class="token1">.</span>title<span class="token1">}</span> 文档数:<span class="token1">{</span>$item<span class="token1">.</span>total<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>channel<span class="token1">}</span>
```
```
## 数据字典
注意:其中`$item`变量根据channel标签id参数影响,默认是:$item
字段名说明调用方式id栏目ID{$[item.id](http://item.id)}model\_id模型ID{$item.model\_id}parent\_id所属父级栏目ID{$item.parent\_id }type栏目类型,link: 外部链接, list:列表栏目,category:栏目首页{$item.type}name栏目英文名称{$[item.name](http://item.name)}title栏目中文名称{$item.title}url链接地址{$item.url}fullurl带域名的URL地址{$item.fullurl}image栏目缩略图{$item.image}seo\_titleseo标题{$item.seo\_title}seo\_keywordsseo关键字{$item.seo\_keywords}seo\_descseo描述{$item.seo\_desc}ismenu是否是导航菜单,1-导航菜单,0-不是{$item.ismenu}targeta标签跳转方式,用于target="\_blank"属性,有\_blank,\_self等{$item.target}weigh排序{$item.weigh}has\_childtrue 有下级,false 没有下级{$item.has\_child}son\_child数组。拥有的下级栏目ID{$item.son\_child}currentstyle当前选中class,用于CSS文字高亮{$item.currentstyle}parent\_url上级栏目的URL地址{$item.parent\_url}lang语言标识{$item.lang}num列表分页大小{$item.num}
- 简介
- 下载与安装配置
- 下载
- 虚拟主机安装
- 百度云虚拟主机
- 创业云虚拟主机
- Linux下宝塔安装
- 宝塔一键部署
- Windows下宝塔安装
- phpEnv下安装
- phpStudy下安装
- 伪静态(url重写)
- 安装系统
- 调试模式与env文件
- 重新安装与安装文件说明
- 后台使用帮助
- 后台入口文件
- 首页面板
- 配置中心
- 站点配置
- SEO设置
- SEO设置-静态生成
- 文档属性
- 站点模块
- V2.2.2版本 -
- V2.2.3版本 +
- 模型管理
- 栏目管理
- 字段类型与组件
- 前言
- 前端组件
- 验证规则
- text 单行文本
- textarea 多行文本
- radio 单选
- checkbox 复选
- select 下拉列表
- selects下拉列表(多)
- selectpage 动态下拉
- editor编辑器
- image图片
- images图片(多)
- number数字
- date日期
- datetime日期和时间
- downfile文件上传
- downfiles文件上传(多)
- array 数组(键值对)
- 内容管理
- 自定义URL
- 多语言
- 界面多语言
- 内容多语言
- 多语言URL地址
- 附件管理
- 应用中心
- 标签语法
- 标签使用必读
- 列表标签
- content 内容列表标签
- contentpage 内容列表分页
- wfpage 瀑布流分页
- filter 筛选标签
- order 排序标签
- 内容标签
- guestbook 留言(表单)标签(废弃)
- form 表单标签
- pre 上一篇标签
- next 下一篇标签
- prenext 上一篇下一篇(高级)标签
- fileinfo 获取附件信息(文件下载)
- 内容分页
- raw 格式化编辑器文本(即将废弃)
- 全局标签
- seo 标签
- channel 栏目标签
- arcone 获取单条文档
- breadcrumb 面包屑导航标签
- adv 站点模块标签
- date 日期格式化标签
- substr字符(标题)截取标签
- volist 循环标签
- language 获取语言列表标签
- query 查询数据库内容
- include 导入模板文件标签
- 原生PHP与php标签
- map生成位置地图
- thumb 生成缩略图
- addons 插件检测
- 标签管理
- taglist标签(获取标签列表)
- tagarclist根据标签获取文章内容列表
- 导入标签
- 模板开发
- 1. 创建模板
- 2. 模板目录结构
- 3. 模板描述文件(重要) info.ini
- 4. 变量输出格式
- 4. 模板变量
- 5. 获取站点配置
- 6. 模板界面多语言
- 7. 模板静态目录及调用静态文件
- 8. 模板定义插件事件
- 9. 模板搜索页
- 10. 模板配置JSON
- 11. 导入演示数据
- 12. 卸载删除演示数据
- 13. 模板文件打包
- 14. 整站源码打包
- 插件开发
- 1. 创建插件
- 2. 目录结构
- 3. 插件名称类
- 4. 插件信息(info.ini)
- 5. 插件事件
- 6. 配置文件
- 7. install 安装目录
- 8. 创建菜单
- 9. 插件控制器
- 10. 插件视图
- 10-1 插件主题化
- 11. 插件模型
- 12. 模型事件
- 13. 插件内置函数
- 13-1 插件函数库
- 14. 插件多语言
- 15. 插件中间件
- 16. 插件路由
- 17. 插件验证器
- 18. 标签库
- 19. 第三方类库
- 20. 数据库文件导入
- 插件打包
- 后台前端使用帮助
- 二次开发帮助(更新中)
- 后台前端开发帮助
- 路由(链接地址、访问规则)
- URL访问
- 路由定义
- URL生成
- 附录
- 数据字典
- 助手函数库