1、模板原理 模板标签在模板文件中使用 标签原理: 标签获取的值都是使用php自定义函数,书写规则必须按照函数规则书写,可以自定义函数使用,函数放在includes/lib.php中 处理标签输出的值可以结合php函数使用 实例:
2、a>{print date('m-d',$v['updatetime'])/}
3、kefu.html 主页、列表页、内容页、地图页为基本页,后台可生成静态页面 自定义的模板在栏目高级设置中设置后使用 模板中使用变量值: 可参考注册文件对应的模板使用 模板标签 书写方式 属性之间用空格分开,标签都不使用单双引号,source指定的函数都按照php函数规则书写 {print $val/}输出标签 用于显示内容到浏览器,和php中的echo一样。 $val可以为函数和循环标签中的$v[]; 如: {print get_block_content('contact_us')/}输出默认模板‘联系我们’片段内容
4、et_channel_content('article','0,4')}
5、loop标签的属性有:source——指定注册的值;tpl——模板位置名称【需要注册模板配置函数】;info——模板位置使用说明;tpl_id——模板位置标示,用于后台处理(字母数字下划线组合)【需要注册模板配置函数】;item——指定输出数组,常用于多维数组输出,输出的值带$ source是必须的,使用tpl_id属性可以在后台配置输出的内容,不使用后台将不会生成该位置配置 如: {loop source=get_article('article') tpl=首页新闻中心 tpl_id=article}{print $v['title']/}{/loop}使用了tpl_id,后台输出配置
6、可以对该位置的内容进行输出设置,tpl和tpl_id不能忽略,tpl_id的值必须是字母和数字、下划线组合,要和source函数中的参数值一样,如加粗蓝色部分 当使用了tpl_id的时候程序会保存该值作为模板的位置,在后台输出配置可以对该位置做相应的配置【要配合配置函数使用】,完全按照意愿配置,不用再在标签中添加修改输出栏目及其它属性 {loop source=get_link()}...{/loop}输出weblink中的值,没有使用tpl_id后台输出设置将不会显示配置位置 使用item如:{loop source=get_link() item=$link}{print $link
7、['name']/}{/loop} 使用item的多级输出如: {loop source=get_link() item=$link} {print $link['name']/} {loop source=$link item=$link_child} {print $link_child['name']/} {/loop} {/loop} 不使用item如:{loop source=get_link()}{print $v['name']/}{/loop} {include foot/}包含标签 包含模板其它文件,多处重复的内容可以另外做成模板,通过include标签引
8、入使用 {path 文件名/}路径标签 用于输出路径 通过{path 目录名/}获得目录路径 几个特殊路径使用如下 {path template/}模板文件夹template路径,可以自动读取当前语言的模板路径 {path index/}首页路径 {path cms/}安装程序根目录 {if *}{else}{/if}判断标签 判断使用 判断的值要带上$ 如: {if $test} {print $test/} {/if} {flash/}主广告标签 输出flash幻灯【后台主广告配置使用】,直接使用 {assign source=* name=*/}
9、1.9新增) source——指定函数 name——获得返回的值 不使用name默认使用$assign 解析为 $assign=get_content(); 只要使用函数的地方都可以使用 如: {assign source=get_tpl_cate_content($tpl_id='1',$limit='0,10',$order_type='',$filter='',$pic='no',$order='',$lang='') name=index_arc/} {if $index_arc} {/if} 常用全局函数 常用函数在includes/lib.php文件中 l
10、ang() 输出语言种类,返回数组
无参数,输出所有语言种类,默认有英文和中文,函数可查看lib.php中的lang()函数
输出:
url:语言链接地址
target:是否新窗口打开,需要后台配置使用,输出格式target="_blank"
class:高亮选中,样式为focus
lang_name:语言名称
first:第一个值
last:最后一个值
显示图片:
后台设置:
使用:
输出为数组,配合{loop}{/loop}标签使用
实例:
{loop source=lang()}
11、t $v['class']/} {print $v['target']/}>{print $v['lang_name']/}
12、出网站基本配置参数 输出: web_name:网站名称 web_powerby:版权信息部分【可以包含统计代码】 keywords:搜索关键词 description:网站描述【seo】 web_beian:网站备案 web_yinxiao:营销代码 使用: 配合{print /}使用 实例: 模板页index.html中输出网站名称{print webinfo('web_name')/} nav_middle()中间导航 无参数,输出中间导航,输出内容可查看lib.php 输出: url:栏目链接地址 class:高亮显示,focus cate_name:栏
13、目名称 target:新窗口打开,输出格式为target="_blank" child:下级栏目数组,输出内容和顶级栏目一样,没有高亮 演示图片: 后台设置: 使用: 和{loop}{/loop}配合使用 实例: 输出顶级栏目: index.html输出顶级 {loop source=nav_middle()} {print $nav_child['cate_
14、name']/}
{/loop}
index.html中输出顶级和下级
{loop source=nav_middle() item=$nav_child}
{print $nav_child['cate_name']/}
{if $nav_child['child']}
{loop source=$nav_child['child']}
15、"{print $v['url']/}" {print $v['target']/}>{print $v['cate_name']/}
17、der='desc',$lang='')输出指定模型表内容 参数必须按顺序 参数: $table:模型表,不带前缀 $limit:数量,和sql语法中的limit一样 $order_type:排序类型,id为按id排序,hits为点击热门排序 $filter:过滤内容,如推荐(a)、头条(b)等 $pic:是否有图片 $order:排序方式,asc和desc两种 $lang:语言,默认程序文件为空可自动获取 输出: title:标题 style:标题样式,直接使用在style里,如style="{print $v['style']/}"格式为color:red(1.9新
18、增) target:新窗口打开 url:链接地址 thumb_pic:缩略图(1.9更改) cate_url:对应栏目地址 cate_name:对应栏目名称 autoindex:输出列表数量值,从1开始,如$limit='0,5',输出从1到5的值 first:判断第一条内容 last:判断最后一条内容 同时可获得模型表和主表中的各字段内容 演示图片: 后台操作: 使用: 配合{loop}{/loop}使用 实例: article_content.html中使用 {loop source=get_channel_content('product','0,
19、5','','b')}
{print cn_substr($v['title'],10)/}{print cn_substr($v['info'],50)/}
20、cate_content($cate_id,$limit='0,5',$order_type='id',$filter='',$pic='no',$order='desc',$lang='')指定栏目内容输出 参数必须按顺序 参数: $cate_id:栏目id $limit:数量,和sql语法中的limit一样 $order_type:排序类型,id为按id排序,hits为点击热门排序 $filter:过滤内容,如推荐(a)、头条(b)等 $pic:是否有图片 $order:排序方式,asc和desc两种 $lang:语言,默认程序文件为空可自动获取 演示图片: 后
21、台操作: 输出: title:标题 style:标题样式,直接使用在style里,如style="{print $v['style']/}"格式为color:red(1.9新增) target:新窗口打开 url:链接地址 thumb_pic:缩略图(1.9更改) cate_url:对应栏目地址 cate_name:对应栏目名称 autoindex:输出列表数量值,从1开始,如$limit='0,5',输出从1到5的值 first:判断第一条内容 last:判断最后一条内容 同时可获得模型表和主表中的各字段内容 使用: 配合{loop}{/loop}使用 实例
22、 同指定模型表一样用法 get_else_content($cate_id='',$limit='0,5',$order_type='id',$filter='',$pic='no',$lang='')指定栏目其它方式输出,内容页列表页默认程序可自动获取栏目id 参数: $cate_id:栏目id $limit:数量,和sql语法中的limit一样 $order_type:排序类型,id为按id排序,hits为点击热门排序 $filter:过滤内容,如推荐(a)、头条(b)等 $pic:是否有图片 $lang:语言,默认程序文件为空可自动获取 只能在列表页、内容页、
23、单页使用 演示图片: 输出: 输出内容和指定栏目内容输出一样 实例: 参考指定栏目输出实例 get_block_content($block='')指定片段(标示)内容输出,不通过后台配置使用 参数: $block:标示名 演示图片: 后台操作: 输出: 标示内容 使用: 配合{print /}使用 实例: article_content.html中使用 {print get_block_content('contact_us')/} get_block('tpl_id')输出片段(标示)内容,通过后台配置使用 tpl_id——模板标签中
24、的tpl_id,和block标签配合使用,只输出后台添加的标示内容 get_hot_words()搜索热门词 无参数,输出网站配置中热门搜索词,自动判断语言 演示图片: 后台操作: 输出: url:关键词链接 name:关键词名 使用: 和{loop}{/loop}配合使用 实例: index.html模板页使用 {loop source=get_hot_words()} {print $v['name']/} {/loop} get_market()客服列表,数组 无参数,输出当前语言添
25、加的客服 输出: market_name:客服名称,如销售客服、技术客服 market_num:客服号码,如电话号码、QQ号码 market_type:客服类型 使用: 配合{loop}{/loop}标签使用 实例: 可参考kefu.html使用 get_link()友情链接,返回数组 无参数,输出友情链接,自动判断语言类型 输出: link_name:链接名称 link_url:链接地址 link_logo:链接logo图片 使用: 配合{loop}{/loop}使用 实例: index.html中使用: {loop source=get_link()}
26、
27、nt webinfo('keywords')/} {print webinfo('description')/} get_list_nav('tpl_id')输出列表页内容页导航列表 tpl_id——模板标签中的tpl_id 参数为空自动获取当前栏目id值 form('tpl_id')输出表单,通过后台配置输出 tpl_id——模板标签form中的tpl_id,和form标签结合使用,返回表单代码 get_form($form_id='')指定输出表单,不通过后台配置使用 参数: $form_id:表单标示名称 输出: 表单 使用: {print get_for
28、m('表单标示')/}使用 get_book_content($limit='0,5',$order='addtime',$is_reply='0',$lang='')获取留言内容 参数: $limit:数量 $order:排序类型,addtime添加时间,id排序 $is_reply:是否回复,1为是,0为否 $lang:指定语言 输出: 输出留言表book中的各字段内容 get_lan_link($cate='')指定栏目输出,常用于输出单个栏目及其更多链接 参数: $cate:栏目ID值 输出: cate_name:栏目名称 url:栏目链接 使
29、用: {loop source=get_lan_link('5')}{print $v['cate_name']/}{/loop} get_web_param($param='')输出程序页中的变量值 参数: $param:程序中的变量名 输出: 变量的值 使用: 如show_content.php中的 $lang 值在模板中使用 {print get_web_param('lang')/} 输出$lang的值 get_table_field_value($id='',$table=
30、'',$field='')根据内容ID获取表中的字段值 该函数必须要存在表和内容才是使用 参数: $id:已经添加的内容ID值 $table:主表或模型表,只能使用一个表 $field:表中的字段,多个字段用,分割 输出: 表中字段的内容 和{loop}{/loop}标签使用 使用: {loop source=get_table_field_value('5','article','content')} {print $v['content']/} {/loop} get_tpl_cate_content($tpl_id='',$limit='0,5',$
31、order_type='id',$filter='',$pic='no',$order='desc',$lang='')根据栏目模板ID指定栏目内容输出 参数必须按顺序 该函数只能配合{assign /}{loop/}标签使用 参数: $tpl_id:栏目模板ID值 $limit:数量,和sql语法中的limit一样 $order_type:排序类型,id为按id排序,hits为点击热门排序 $filter:过滤内容,如推荐(a)、头条(b)等 $pic:是否有图片 $order:排序方式,asc和desc两种 $lang:语言,默认程序文件为空可自动获取 演示图片:
32、 后台操作: 输出: 输出2个数组,栏目信息和列表内容 栏目为arr['cate'],配合{print /}使用 arr['cate']['cate_url']:对应栏目地址 arr['cate']['cate_name']:对应栏目名称 arr['cate']['target']:是否新窗口 arr['cate']['cate_pi1']:栏目图片1 arr['cate']['cate_pi2']:栏目图片2 arr['cate']['cate_pi3']:栏目图片3 arr['cate']['cate_content']:栏目内容 内容列表为arr['conte
33、nts'],配合{loop}{/loop}使用,输出内容和上面的函数内容一样 arr['contents']['title']:标题 arr['contents']['style']:标题样式,直接使用在style里,如style="{print $v['style']/}"格式为color:red(1.9新增) arr['contents']['target']:新窗口打开 arr['contents']['url']:链接地址 arr['contents']['thumb_pic']:缩略图(1.9更改) arr['contents']['autoindex']:输出列表数量值
34、从1开始,如$limit='0,5',输出从1到5的值 arr['contents']['first']:判断第一条内容 arr['contents']['last']:判断最后一条内容 同时可获得模型表和主表中的各字段内容 使用: 配合{assing/}{loop}{/loop}{print /}使用 实例: {assign source=get_tpl_cate_content($tpl_id='1',$limit='0,10',$order_type='',$filter='',$pic='no',$order='',$lang='') name=index_arc/}
35、 {if $index_arc}
36、ref="{print $v['url']/}" {print $v['target']/} {if $v['style']}style="{print $v['style']/}"{/if}>{print cn_substr($v['title'],40)/}
{print date('m-d',$v['updatetime'])/}37、type='id',$filter='',$pic='no',$order='desc',$lang='')根据栏目模板ID输出该栏目的下级栏目及其内容(1.9新增) 参数必须按顺序 该函数只能配合{assign /}{loop/}标签使用,该函数实例可以参考默认模板 参数: $tpl_id:栏目模板ID值 $content:是否输出内容列表,no为否,yes为是 $limit:数量,和sql语法中的limit一样 $order_type:排序类型,id为按id排序,hits为点击热门排序 $filter:过滤内容,如推荐(a)、头条(b)等 $pic:是否有图片 $ord
38、er:排序方式,asc和desc两种 $lang:语言,默认程序文件为空可自动获取 演示图片: 后台操作: 输出: 输出2个数组,栏目信息和列表内容 栏目为arr['cate'],配合{print /}使用 arr['cate']['cate_url']:对应栏目地址 arr['cate']['cate_name']:对应栏目名称 arr['cate']['target']:是否新窗口 arr['cate']['cate_pi1']:栏目图片1 arr['cate']['cate_pi2']:栏目图片2 arr['cate']['cate_pi3']:栏目图片3
39、 arr['cate']['cate_content']:栏目内容 内容列表为arr['contents'],配合{loop}{/loop}使用,输出内容和上面的函数内容一样 arr['contents']['title']:标题 arr['contents']['style']:标题样式,直接使用在style里,如style="{print $v['style']/}"格式为color:red arr['contents']['target']:新窗口打开 arr['contents']['url']:链接地址 arr['contents']['thumb_pic']:缩略图
40、 arr['contents']['autoindex']:输出列表数量值,从1开始,如$limit='0,5',输出从1到5的值 arr['contents']['first']:判断第一条内容 arr['contents']['last']:判断最后一条内容 同时可获得模型表和主表中的各字段内容 使用: 配合{assing/}{loop}{/loop}{print /}使用 实例: {assign source=get_all_cate_content($tpl_id='2',$content='yes',$limit='0,8',$order_type='id',$filt
41、er='',$pic='no',$order='desc',$lang='') name=arc/} {if $arc} {loop source=$arc item=$arc_v}
42、source=$arc_v['contents']}
43、oop} {/if} get_tpl_list_nav($tpl_id='')根据栏目模板ID输出该栏目的下级栏目(1.9新增) 参数必须按顺序 参数: $tpl_id:栏目模板ID值,为空自动获取当前栏目ID值 演示图片: 后台操作: 输出: url:对应栏目地址 cate_name:对应栏目名称 target:是否新窗口 cate_pi1:栏目图片1 cate_pi2:栏目图片2 cate_pi3:栏目图片3 cate_content:栏目内容 class:高亮选中样式 child:栏目的下级栏目(数组) 使用: 配合{assing
44、/}{loop}{/loop}{print /}使用 实例: 用法和后台配置那个函数一样 常用列表页函数 常用函数在includes/lib.php文件中 cateinfo($param='')栏目信息,用于SEO优化 输出栏目信息 输出: cate_name:栏目名称(1.9更改) cate_title_seo:栏目标题(1.9更改) cate_key_seo:栏目关键词(1.9更改) cate_info_seo:栏目描述(1.9更改) 使用: 配合{print /}使用 实例: list_article.html中使用 {print $cateinfo['k
45、eywords']/} {print $cateinfo['description']/} get_list_nav('tpl_id')输出列表页内容页导航列表 参数: tpl_id——模板标签中的tpl_id,使用tpl_id后台可进行配置 参数为空会自动获取当前栏目的下级栏目 输出: url:栏目链接 class:高亮显示,默认为focus; cate_name:栏目名称 id:栏目ID child:栏目下级栏目 first:第一个值 last:最后一个值 target:新窗口打开 使用: 配合{loop}{/loop}标签使用 实例: list_art
46、icle.html模板页中使用 使用后台配置 {loop source=get_list_nav('list_nav1') tpl=列表页导航 tpl_id=list_nav1} {print $nav['cate_name']/} {/loop} 自动获取栏目 {loop source=get_list_nav('') item=
47、nav}
{print $nav['cate_name']/}
{/loop}
输出下级栏目:
{loop source=get_list_nav('') item=$nav}
48、rget']/} title="{print $nav['cate_name']/}">{print $nav['cate_name']/}
49、t:新窗口打开 url:链接地址 thumb_pic:缩略图(1.9更改) first:第一个值 last:最后一个值 可输出主表maintb和栏目的附加表(如文章栏目附加表article)中的字段值 使用: 配合{loop}{/loop}标签使用 实例: list_article.html中使用 {loop source=list_article()} {print $v['style_title']/}
50、 {/loop} list_page()列表页分页 无参数,返回列表页html代码,格式为首页 实例: list_article.html中使用 {print list_page()/} 常用内容页函数 常用函数在includes/lib.php文件中 content($param='')基本内容输出 该函数主要用于输出程序文件show_content.php中的变量$content的值 参数: $param:输出各内容部分 实例: article_content.htm中使用 {print content('主表和附加表各字段内容'






