文档介绍:Cute
Uintage style
PHPCMS开发实例PHPCMS二次开发模板
Add your text here and write down your opninon thank you add your text hereCute
Uintage style
PHPCMS开发实例PHPCMS二次开发模板
Add your text here and write down your opninon thank you add your text here
U
i
n
t
a
g
e
U
i
n
t
a
g
e
PHPCMS V9 的目录结构
什么是模板
用于将程序整理好的数据与模板文件进行绑定,并输出到客户端浏览器。
模板的基本语法——定界符
PHPCMS模板标签 使用{}作为定界符
{标签内容}
模板的基本语法——输出变量
{$variable_name}
输出标签中变量的值。
参考:
<?php echo $variable_name; ?>
<?=$variable_name?>
模板的基本语法——输出常量
{constant_name}输出标签中常量的值。
参考:
<?php echo constant_name; ?>
<?= constant_name?>
模板的基本语法——条件判断
{if expression1}
statement1
{elseif expression2}
statement2 ……
{elseif expressionN}
statement
{else}
statement
{/if}条件判断,当符合条件则执行对应的程序
参考:
if( expression1 ){
statement1
}elseif( expression2 ){
statement2
}……
else{
statement;
}
模板的基本语法——循环
{loop $a $n $b} statement{/loop}
遍历数组,并执行循环内部的程序。
参考:
foreach( $a as $b ){
statement
}
模板的基本语法——调用其他模板
{template ‘template_file_path’, ‘template_file_name’}
调用其他模板文件。
模板文件目录(template_file_path)为当前使用的模板风格所在目录的相对路径。
默认路径:phpcms_root/phpcms/templates/default。
获取推荐位列表
{pc:content action=‘position’ posid=‘’ catid=‘’ thumb=‘’ where=‘’ order=‘’ num=‘’}{/pc}
返回参数
字段
类型
空
默认
注释
title
char(80)
否
NULL
推荐位标题
url
char
否
NULL
推荐位链接地址
inputtime
int(10)
否
NULL
推荐位发布时间
thumb
char
是
NULL
推荐位缩略图
例如:
{pc:content action="position" posid="2" order="listorder DESC" num="4"}
<ul>
{loop $data $key $val}
<li><a href="{$val['url']}">{$val['title']}</a></li>
{/loop}
</ul>
{/pc}
PC标签——评论模块
PC标签——投票模块
PC标签——公告模块
PC标签——专题模块
PC标签——会员模块
PC标签——友情链接模块
PC标签——工具箱
PC标签——JSON工具箱
{pc:json}……{/pc}
{pc:json url=“test_url" cache="86400"}
{loop $data $key $val}
<a href="{$val[url]}">{$val['title']}</a>
{/loop}
{/pc}
参数
默认值
说明
url
null
要读取的JSON数据来源
cache
0
缓存时间,对读取的数据进行数据缓存,单位为秒。不设置该值表示不需要进行缓存
return
data
返回数组名。默认值为data
PC标签——XML工具箱
{pc:xml}……{/pc}
{pc:xml url=“test_url" cache="86400"}
{loop $data