常用函数在includes/lib.php文件中
无参数,输出所有语言种类,默认有英文和中文,函数可查看lib.php中的lang()函数
输出:
url:语言链接地址
target:是否新窗口打开,需要后台配置使用,输出格式target="_blank"
class:高亮选中,样式为focus
lang_name:语言名称
first:第一个值
last:最后一个值
显示图片:
后台设置:
使用:
输出为数组,配合{loop}{/loop}标签使用
实例:
{loop source=lang()}
<a href="{print $v['url']/}" {print $v['class']/} {print $v['target']/}>{print $v['lang_name']/}</a>
{/loop}
输出网站语言包,常用于一套模板多种语言网站
$parama:语言包中的语言标示
显示图片:
后台设置:
输出:
输出语言包中各参数,用标示输出
使用:
配合{print /}使用
实例:
模板中输出:{print weblangs('contact')/}
$param:输出网站基本配置参数
输出:
web_name:网站名称
web_powerby:版权信息部分【可以包含统计代码】
keywords:搜索关键词
description:网站描述【seo】
web_beian:网站备案
web_yinxiao:营销代码
使用:
配合{print /}使用
实例:
模板页index.html中输出网站名称{print webinfo('web_name')/}
无参数,输出中间导航,输出内容可查看lib.php
输出:
url:栏目链接地址
class:高亮显示,focus
cate_name:栏目名称
target:新窗口打开,输出格式为target="_blank"
child:下级栏目数组,输出内容和顶级栏目一样,没有高亮
演示图片:
后台设置:
使用:
和{loop}{/loop}配合使用
实例:
输出顶级栏目:
index.html输出顶级
{loop source=nav_middle()}
<a href="{print $nav_child['url']/}" class="{print $nav_child['class']/}" {print $nav_child['target']/}>{print $nav_child['cate_name']/}</a>
{/loop}
index.html中输出顶级和下级
{loop source=nav_middle() item=$nav_child}
<a href="{print $nav_child['url']/}" class="{print $nav_child['class']/}" {print $nav_child['target']/}>{print $nav_child['cate_name']/}</a>
{if $nav_child['child']}
{loop source=$nav_child['child']}
<a href="{print $v['url']/}" {print $v['target']/}>{print $v['cate_name']/}</a>
{/loop}
{/if}
{/loop}
无参数,输出底部导航,输出内容可查看lib.php
输出:
url:栏目链接
target:新窗口打开
cate_name:栏目名称
first:第一个值
last:最后一个值
使用:
配合{loop}{/loop}使用
实例:
foot.html模板页使用标签
{loop source=nav_bottom()}
<a href="{print $v['url']/}" title="{print $v['cate_name']/}">{print $v['cate_name']/}</a>{if !$v['last']}|{/if}
{/loop}
tpl_id——模板标签中的tpl_id,和loop标签配合使用,输出内容可查看lib.php
图片演示:
后台操作:
get_channel_content($table,$limit='0,5',$order_type='id',$filter='',$pic='no',$order='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新增)
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,5','','b')}
<a title="{print $v['title']/}" {print $v['target']/} href="{print $v['url']/}"><img src="{print $v['tbpic']/}" alt="{print $v['title']/}" border="0" /><p><span class="title">{print cn_substr($v['title'],10)/}</span><span>{print cn_substr($v['info'],50)/}</span></p></a>
{/loop}
get_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:语言,默认程序文件为空可自动获取
演示图片:
后台操作:
输出:
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}使用
实例:
同指定模型表一样用法
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:语言,默认程序文件为空可自动获取
演示图片:
输出:
输出内容和指定栏目内容输出一样
实例:
参考指定栏目输出实例
get_block_content($block='')指定片段(标示)内容输出,不通过后台配置使用
参数:
$block:标示名
演示图片:
后台操作:
输出:
标示内容
使用:
配合{print /}使用
实例:
article_content.html中使用
{print get_block_content('contact_us')/}
tpl_id——模板标签中的tpl_id,和block标签配合使用,只输出后台添加的标示内容
无参数,输出网站配置中热门搜索词,自动判断语言
演示图片:
后台操作:
输出:
url:关键词链接
name:关键词名
使用:
和{loop}{/loop}配合使用
实例:
index.html模板页使用
{loop source=get_hot_words()}
<a href="{print $v['url']/}">{print $v['name']/}</a>
{/loop}
无参数,输出当前语言添加的客服
输出:
market_name:客服名称,如销售客服、技术客服
market_num:客服号码,如电话号码、QQ号码
market_type:客服类型
使用:
配合{loop}{/loop}标签使用
实例:
可参考kefu.html使用
无参数,输出友情链接,自动判断语言类型
输出:
link_name:链接名称
link_url:链接地址
link_logo:链接logo图片
使用:
配合{loop}{/loop}使用
实例:
index.html中使用:
{loop source=get_link()}
<li><a href="{print $v['link_url']/}">{print $v['link_name']/}</a></li>
{/loop}
输出栏目信息
$param:输出的内容
输出:
cate_name:栏目名称(1.9更改)
cate_title_seo:栏目标题(1.9更改)
cate_key_seo:栏目关键词(1.9更改)
cate_info_seo:栏目描述(1.9更改)
使用:
配合{print /}使用
实例:
list_article.html中使用
{print webinfo('keywords')/}
{print webinfo('description')/}
tpl_id——模板标签中的tpl_id
参数为空自动获取当前栏目id值
tpl_id——模板标签form中的tpl_id,和form标签结合使用,返回表单代码
get_form($form_id='')指定输出表单,不通过后台配置使用
参数:
$form_id:表单标示名称
输出:
表单
使用:
{print get_form('表单标示')/}使用
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:栏目链接
使用:
{loop source=get_lan_link('5')}<a href="{print $v['url']/}">{print $v['cate_name']/}</a>{/loop}
get_web_param($param='')输出程序页中的变量值
参数:
$param:程序中的变量名
输出:
变量的值
使用:
如show_content.php中的 $lang 值在模板中使用
{print get_web_param('lang')/} 输出$lang的值
get_table_field_value($id='',$table='',$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',$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:语言,默认程序文件为空可自动获取
演示图片:
后台操作:
输出:
输出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['contents'],配合{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']:输出列表数量值,从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/}
{if $index_arc}
<div class="box">
<div class="left_title"><h2><a href="{print $index_arc['cate']['cate_url']/}">{print $index_arc['cate']['cate_name']/}</a></h2></div>
<div class="box_in">
<div class="news_list">
<ul>
{loop source=$index_arc['contents']}
<li><a title="{print $v['title']/}" href="{print $v['url']/}" {print $v['target']/} {if $v['style']}style="{print $v['style']/}"{/if}>{print cn_substr($v['title'],40)/}</a>{print date('m-d',$v['updatetime'])/}</li>
{/loop}
</ul>
</div>
</div>
</div>
{/if}
get_all_cate_content($tpl_id='',$content='no',$limit='0,5',$order_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:是否有图片
$order:排序方式,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
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']:缩略图
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',$filter='',$pic='no',$order='desc',$lang='') name=arc/}
{if $arc}
{loop source=$arc item=$arc_v}
<div class="box">
<div class="left_title"><h2><a href="{print $arc_v['cate']['cate_url']/}">{print $arc_v['cate']['cate_name']/}</a></h2></div>
<div class="box_in">
<div class="news_list">
<ul>
{loop source=$arc_v['contents']}
<li><a title="{print $v['title']/}" href="{print $v['url']/}" {print $v['target']/} {if $v['style']}style="{print $v['style']/}"{/if}>{print cn_substr($v['title'],40)/}</a>{print date('m-d',$v['updatetime'])/}</li>
{/loop}
</ul>
</div>
</div>
</div><!--容器结束-->
{/loop}
{/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/}{loop}{/loop}{print /}使用
实例:
用法和后台配置那个函数一样