内建函数
按照smarty的要求去用
config_load:加载配置文件
file=”配置文件名称”
section=”区域名称”
在加载时类似html
$tpl->configs=”./configs” //基准路径
./configs/dir_1/a.conf
<{config_load file=”dir_1/a.conf” section=”one”}>相对于
Include:
标签用于在当前模板中包含其它模板. 当前模板中的变量在被包含的模板中可用
<{include file=”header.php”}>
<{include file=”footer.php”}>
Capture:
捕获模板输出的数据并将其存储到一个变量里,而不是把它们输出到页面.
<{capturename=”自定义区域名”}>
Aaaaaaaaaaaa
<{$name}>
<{includefile=”head.tpl”}>
…….
<{/capture}>
<{$smarty.capture.自定义区域名}>
foreache,foreachelse
功能和语法与php当中类似,====foreach
Foreach($rowas $key=>$value){
…
}
效率稍差;
For($i=0;$i<5;$i++){
}
变量
$smarty.foreach.循环名.变量名
Iteration:用于显示当前循环的执行次数,从1开始,每执行一次
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
Section,sectionelse: 针对PHP中的for循环 推荐使用
功能和效率要比foreach好
只针对索引数组,
Section 显示二维数组 loop
Section 不能处理下标不连续的数组