smarty内建函数
来源:互联网 发布:sql 选取最大值 编辑:程序博客网 时间:2024/05/17 23:16
内建函数
按照smarty的要求去用
config_load :加载配置文件
file= “配置文件名称”
section=“区域名称”
$tpl->configs=”./configs” //基准路径
./configs/dir_1/a.conf
<{config_load file=” dir_1/a.conf” section=“one” }>
include :
标签用于在当前模板中包含其它子模板.
当前模板中的变量在被包含的子模板中可用
<{include file=”header.tpl”}>
<{include file=”footer.html”}>
capture
捕获模板输出的数据并将其存储到一个变量里,而不是把它们输出到页面.
任何在 {capture name="foo"}和{/capture}之间的数据将被存储到变量$foo中,该变量由name属性指定.
在模板中通过 $smarty.capture.foo访问该变量.
如果没有指定 name 属性,函数默认将使用 "default" 作为参数.
{capture}必须成对出现,即以{/capture}作为结尾,该函数不能嵌套使用.
<{capture name=”自定义区域名”}>
aAaaaaaaaaaaaaa
<{$name}>
<{include file=”head.tpl”}>
……
<{/capture}>
<{$smarty.capture.自定义区域名}>
foreach,foreachelse
功能和语法与php当中类似,====foreach
foreach($row as $key=>$value){
…
}
效率差;
for($i=0;$i<5;$i++){ }
变量
$smarty.foreach.循环名.变量名
iteration :用于显示当前循环的执行次数,从1开始,每执行一次增加 1
first :
last
show
total
section,sectionelse (推荐)for
功能和效率要比foreach好
只针对索引数组
section 显示二维数组 loop
section 不能处理下标不连续的数组
if,elseif,else
eq(相等)、ne(不等)、neq(不等)、gt
(大于)、lt(小于)、lte(小于等于)、le(小于等于)、gte(大于等于)、ge(大于等于)、>、<、<=、>=.==、!=、
is even、is odd、is not even、is not odd、not、mod、div by、even by、odd by、
- smarty内建函数
- smarty 内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- SMARTY内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- smarty内建函数
- Smarty内建函数
- Smarty内建函数
- smarty的内建函数
- smarty内建函数简介
- (Flash CS5) Java运行时环境初始化时出现错误,你可能需要重新安装Flash(CS5)
- U-Boot编译过程完全分析
- 设置UIView 背景图片二方法
- DataReader用法
- mysql变量使用总结
- smarty内建函数
- JS实现图片翻书效果
- Boot Memory分配器
- window.parent和window.opener区别
- 什么是SyncML
- 策略模式实现
- 再谈OpenCV
- 道理
- 在 GridView 控件中添加一列复选框