內建函數
按照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 name="foo"}和{/capture}之間的數據將被存儲到變量$foo中,該變量由name屬性指定.
在模板中通過 $smarty.capture.foo 訪問該變量.
如果沒有指定 name 屬性,函數默認將使用 "default" 作爲參數.
{capture}必須成對出現,即以{/capture}作爲結尾,該函數不能嵌套使用.
<{capture name=”自定義區域名”}>
aAaaaaaaaaaaaaa
<{$name}>
<{include file=”head.tpl”}>
……
<{/capture}>
<{$smarty.capture.自定義區域名}>
功能和語法與php當中類似,====foreach
foreach($row as $key=>$value){
…
}
效率差;
for($i=0;$i<5;$i++){ }
變量
$smarty.foreach.循環名.變量名
iteration :用於顯示當前循環的執行次數,從1開始,每執行一次增加 1
first :
section,sectionelse (推薦)for
功能和效率要比foreach好
只針對索引數組
section 顯示二維數組 loop
section 不能處理下標不連續的數組
literal