多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# adv 站点模块标签 - [站点模块标签](#_1) - [简单示例](#_4) - [参数](#_14) - [获取图集](#_42) - [获取多媒体](#_89) - [获取HTML](#HTML_118) - [获取内容数据](#_134) - [获取文字链接](#_142) ## 站点模块标签 站点模块标签调用的是后台站点模块数据,支持图集,多媒体,HTML内容,内容数据模块。 ## 简单示例 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"home-banner"</span><span class="token1">}</span> <span class="token"><</span>div style<span class="token">=</span><span class="token4">"background-image:url({$item.image});"</span><span class="token">></span> 数组的索引:<span class="token1">{</span>$key<span class="token1">}</span> 循环变量:<span class="token1">{</span>$i<span class="token1">}</span>,第几次循环,从<span class="token3">1</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>adv<span class="token1">}</span> ``` ``` ## 参数 > HkCms\_v2.1.210909之后版本itemid获取的是排序序号。以添加图集时的顺序,从1开始 参数名称可选值默认值是否必填说明name--是模块标识,即后台站点模块里面的标识,每一个模块都有标识itemid---模块子项序号,用于显示特定图集、视频cache-3600秒-缓存时间,默认3600秒id-$item-指定循环里的变量名,例如id='obj',模板调用如:{$item.title} 变成 {$obj.title}empty---为空的时候输出提示,支持传入htmlcurrentstyle-active-指定选中的图片,class名称具体看下面示例current-1-指定第几个选中,默认active class给到第一个num格式为数字,或传入变量--限制数量- `name`,模块唯一标识,值为站点模块添加时所填写的标识,如下图所示 ![](https://img.kancloud.cn/96/7c/967c6235de33d41282826de36f5ccbd0_621x227.png) - `currentstyle`,选中的class,例如class等于active,假设第二张图片为加载页面后首先看到的,那么current="2",第二张图集currentstyle里面就有值为active。控制哪个图片有active就首先显示出来。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"home_banner"</span> currentstyle<span class="token">=</span><span class="token4">"active"</span> current<span class="token">=</span><span class="token4">"2"</span><span class="token1">}</span> <span class="token5">// 只有第二张才有currentstyle才有值,这里是文字演示,具体的要根据你的轮播图插件来。</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">"{$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>adv<span class="token1">}</span> ``` ``` ## 获取图集 假设获取默认演示数据的`home_banner`标识的图集 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"home_banner"</span><span class="token1">}</span> 图片:<span class="token1">{</span>$item<span class="token1">.</span>image<span class="token1">}</span> <span class="token"><</span>br<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="token1">{</span>$item<span class="token1">.</span>notes<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 跳转地址:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> a标签跳转方式:<span class="token1">{</span>$item<span class="token1">.</span>target<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 选中的class:<span class="token1">{</span>$item<span class="token1">.</span>currentstyle<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>adv<span class="token1">}</span> ``` ``` a标签跳转方式由添加图集时是否开启新窗口打开,开启后target就会等于:target=\_blank。 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"home_banner"</span><span class="token1">}</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{$item.url}"</span> <span class="token1">{</span>$item<span class="token1">.</span>target<span class="token1">}</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>adv<span class="token1">}</span> ``` ``` 结果示例 ``` <pre class="calibre16">``` <span class="token"><</span>a href<span class="token">=</span><span class="token4">"#"</span> target<span class="token">=</span><span class="token4">"_blank"</span><span class="token">></span>宣传视频<span class="token"><</span><span class="token">/</span>a<span class="token">></span> ``` ``` 只获取第二张图片,使用itemid参数 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"home_banner"</span> itemid<span class="token">=</span><span class="token4">"2"</span><span class="token1">}</span> <span class="token"><</span>img src<span class="token">=</span><span class="token4">"image"</span><span class="token">></span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>adv<span class="token1">}</span> ``` ``` **常用字段说明** 注意:其中`$item`变量根据id参数影响,默认是:$item 字段名说明调用方式type类型,1=图集,2=多媒体,3=html,4=内容数据,5=文字链接{$item.type}title图集里面的标题{$item.title}image图片地址{$item.image}url跳转地址{$item.url}notes描述{$item.notes}weigh排序{$item.weigh}currentstyleclass值,选中的图片才有值{$item.currentstyle}target标签跳转方式{$item.target}recommend一维数组,图集组的信息-name图集组的标识名称{$[item.recommend.name](http://item.recommend.name)}remark图集组标题{$item.recommend.remark}## 获取多媒体 基本与图集使用一致,唯一的区别是资源地址是content字段 ``` <pre class="calibre16">``` <span class="token5">// 假设多媒体标识名叫video,那么如下获取</span> <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"video"</span><span class="token1">}</span> 资源地址:<span class="token1">{</span>$item<span class="token1">.</span>content<span class="token1">}</span> <span class="token"><</span>br<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="token1">{</span>$item<span class="token1">.</span>notes<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 跳转地址:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> a标签跳转方式:<span class="token1">{</span>$item<span class="token1">.</span>target<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 选中的class:<span class="token1">{</span>$item<span class="token1">.</span>currentstyle<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>adv<span class="token1">}</span> ``` ``` **常用字段说明** 注意:其中`$item`变量根据id参数影响,默认是:$item 字段名说明调用方式type类型,1=图集,2=多媒体,3=html,4=内容数据,5=文字链接{$item.type}title多媒体类型标题{$item.title}content资源地址{$item.image}url跳转地址{$item.url}notes描述{$item.notes}weigh排序{$item.weigh}currentstyleclass值,选中的图片才有值{$item.currentstyle}target标签跳转方式{$item.target}recommend一维数组,组的信息-name组的标识名称{$[item.recommend.name](http://item.recommend.name)}remark组的标题{$item.recommend.remark}## 获取HTML 假设HTML标识名叫`links`,那么如下获取 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"links"</span><span class="token1">}</span> <span class="token1">{</span>$item<span class="token1">.</span>content<span class="token1">}</span> <span class="token5">// 输出HTML</span> <span class="token1">{</span><span class="token">/</span>hkcms<span class="token1">:</span>adv<span class="token1">}</span> ``` ``` **常用字段说明** 注意:其中`$item`变量根据id参数影响,默认是:$item 字段名说明调用方式content资源地址{$item.image}recommend一维数组,组的信息-name组的标识名称{$[item.recommend.name](http://item.recommend.name)}remark组的标题{$item.recommend.remark}## 获取内容数据 字段是根据选择的模型而定的,字段名可前往模型管理》字段管理里面设置。 获取内容数据示例: ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"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="token">/</span>hkcms<span class="token1">:</span>adv<span class="token1">}</span> ``` ``` ## 获取文字链接 ``` <pre class="calibre16">``` <span class="token1">{</span>hkcms<span class="token1">:</span>adv name<span class="token">=</span><span class="token4">"link"</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>notes<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 跳转地址:<span class="token1">{</span>$item<span class="token1">.</span>url<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> a标签跳转方式:<span class="token1">{</span>$item<span class="token1">.</span>target<span class="token1">}</span> <span class="token"><</span>br<span class="token">></span> 选中的class:<span class="token1">{</span>$item<span class="token1">.</span>currentstyle<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>adv<span class="token1">}</span> ``` ``` **常用字段说明** 注意:其中`$item`变量根据id参数影响,默认是:$item 字段名说明调用方式title标题{$item.title}url跳转地址{$item.url}notes描述{$item.notes}weigh排序{$item.weigh}currentstyleclass值,选中的图片才有值{$item.currentstyle}target标签跳转方式{$item.target}recommend一维数组,图集组的信息-name图集组的标识名称{$[item.recommend.name](http://item.recommend.name)}remark图集组标题{$item.recommend.remark}