bees标签制作说明_bees模板标签制作说明
bees标签制作说明由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“bees模板标签制作说明”。
模板原理
模板标签在模板文件中使用
标签原理:
标签获取的值都是使用php自定义函数,书写规则必须按照函数规则书写,可以自定义函数使用,函数放在includes/lib.php中
处理标签输出的值可以结合php函数使用
实例:
{loop source=get_article('index_1')tpl=案例展示 tpl_id=index_1} {print $v['style_title']/}{print date('m-d',$v['updatetime'])/} {/loop}
模板结构
模板统一放在template文件下,新建立目录保存模板,使用模板时通过目录名使用模板
如默认中文模板目录为default,在网站设置中模板风格为default 默认主要文件: 主页:index.html 列表页:list_内容模型名.html 内容页:内容模型名_content.html 表单页:list_order.html 地图页:sitemap.html 用户页:member_login.html 留言页:book.html 客服页:kefu.html 主页、列表页、内容页、地图页为基本页,后台可生成静态页面
自定义的模板在栏目高级设置中设置后使用
模板中使用变量值:
可参考注册文件对应的模板使用
模板标签
书写方式
属性之间用空格分开,标签都不使用单双引号,source指定的函数都按照php函数规则书写
{print $val/}输出标签
用于显示内容到浏览器,和php中的echo一样。
$val可以为函数和循环标签中的$v[];如: {print get_block_content('contact_us')/}输出默认模板‘联系我们’片段内容
{loop source=get_channel_content('article','0,4')} {print cn_substr($v['title'],50)/}{print date('Y-m-d',$v['updatetime'])/} {/loop} 循环输出文章模型中的4条内容
{loop *}{/loop}循环标签
主要用于输出多条内容,和单条内容中的多个信息,如根据ID值获取表中的多个字段内容
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,后台输出配置可以对该位置的内容进行输出设置,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['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标签引入使用
{path 文件名/}路径标签
用于输出路径
通过{path 目录名/}获得目录路径
几个特殊路径使用如下
{path template/}模板文件夹template路径,可以自动读取当前语言的模板路径 {path index/}首页路径 {path cms/}安装程序根目录
{if *}{else}{/if}判断标签
判断使用
判断的值要带上$ 如:
{if $test} {print $test/} {/if} {flash/}主广告标签 输出flash幻灯【后台主广告配置使用】,直接使用
{aign source=* name=*/}(1.9新增)
source——指定函数
name——获得返回的值
不使用name默认使用$aign 解析为 $aign=get_content();只要使用函数的地方都可以使用
如:
{aign 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文件中 lang()输出语言种类,返回数组
无参数,输出所有语言种类,默认有英文和中文,函数可查看lib.php中的lang()函数
输出:
url:语言链接地址
target:是否新窗口打开,需要后台配置使用,输出格式target=“_blank” cla:高亮选中,样式为focus lang_name:语言名称
first:第一个值
last:最后一个值
显示图片:
后台设置:
使用:
输出为数组,配合{loop}{/loop}标签使用
实例:
{loop source=lang()} {print $v['lang_name']/} {/loop} weblangs($param='')输出语言包,返回数组
输出网站语言包,常用于一套模板多种语言网站
$parama:语言包中的语言标示 显示图片:
后台设置:
输出: 输出语言包中各参数,用标示输出
使用:
配合{print /}使用
实例:
模板中输出:{print weblangs('contact')/} webinfo($param='')网站配置信息,常用于seo优化,返回数组
$param:输出网站基本配置参数
输出: web_name:网站名称
web_powerby:版权信息部分【可以包含统计代码】
keywords:搜索关键词
description:网站描述【seo】
web_beian:网站备案 web_yinxiao:营销代码
使用:
配合{print /}使用
实例:
模板页index.html中输出网站名称{print webinfo('web_name')/} nav_middle()中间导航
无参数,输出中间导航,输出内容可查看lib.php 输出:
url:栏目链接地址
cla:高亮显示,focus cate_name:栏目名称
target:新窗口打开,输出格式为target=“_blank” child:下级栏目数组,输出内容和顶级栏目一样,没有高亮
演示图片:
后台设置:
使用:
和{loop}{/loop}配合使用
实例:
输出顶级栏目:
index.html输出顶级
{loop source=nav_middle()} {print $nav_child['cate_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']} {print $v['cate_name']/} {/loop} {/if} {/loop} nav_bottom()底部导航
无参数,输出底部导航,输出内容可查看lib.php 输出:
url:栏目链接 target:新窗口打开
cate_name:栏目名称
first:第一个值
last:最后一个值
使用:
配合{loop}{/loop}使用
实例:
foot.html模板页使用标签
{loop source=nav_bottom()} {print $v['cate_name']/}{if!$v['last']}|{/if} {/loop} get_article('tpl_id')输出内容列表,通过后台配置使用
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')}
{print cn_substr($v['title'],10)/}{print cn_substr($v['info'],50)/}
{/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')/} get_block('tpl_id')输出片段(标示)内容,通过后台配置使用
tpl_id——模板标签中的tpl_id,和block标签配合使用,只输出后台添加的标示内容
get_hot_words()搜索热门词 无参数,输出网站配置中热门搜索词,自动判断语言
演示图片:
后台操作:
输出:
url:关键词链接
name:关键词名
使用:
和{loop}{/loop}配合使用
实例:
index.html模板页使用
{loop source=get_hot_words()} {print $v['name']/} {/loop} get_market()客服列表,数组
无参数,输出当前语言添加的客服
输出: 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()} {print $v['link_name']/} {/loop} cateinfo($param='')栏目信息,用于SEO优化
输出栏目信息
$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')/} 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_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')}{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='',$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指定栏目内容输出 参数必须按顺序
该函数只能配合{aign /}{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']:判断最后一条内容
同时可获得模型表和主表中的各字段内容
使用:
配合{aing/}{loop}{/loop}{print /}使用
实例:
{aign source=get_tpl_cate_content($tpl_id='1',$limit='0,10',$order_type='',$filter='',$pic='no',$order='',$lang='')name=index_arc/} {if $index_arc} {print $index_arc['cate']['cate_name']/}