smarty總結(一)

 

 

1、        自定義函數(自定義標籤)

1)        php文件function定義函數

註冊步驟(register_function()、register_block())

Tpl文件類似於html標籤

  <{title  num=”10” }>

         成對出現---塊

           <{tilte}>……..<{/title}>

      2)當作插件

         ./plugins

           *.function.*.php

              Function  smarty_function.

*.block.*.php

              Function  smarty_block.

 

         擴展smarty標籤功能模塊,自己進行編輯

2、        內建函數

       Include:包含子模板,子模板中也可以使用當前頁聲明的smarty變量;

             Include(“head.tpl”);

       config_load:界面的調整

             <config_load   file=””  section=”one”>

       Capture:   <{capture}> …… <{/capture}>

                $smarty.capture.

       If ..elseif …else  /if: elseif中間不要出現空格

                        條件表達式不要加()

                    == ><

                   Eq gt lt ge le

         

      Foreach---foreach   關聯數組  索引數據

        From =“要循環的數組名” name=”name1”  item=

        變量:$smarty.foreach.name1.first  last  total  etc.

           Section---for       索引數組

               $data[]=$row;

             Name=”out”

             $data[out].ip

      …..

          Start   step   max

     

  PHP

     

 

Cache:提高效率

     *.php  *.tpl

       smarty---   合併後編譯  (php與html混合)

                 templates_c

                        *.php

        優點:省略了重新合併、編譯的時間;

              連接數據庫不能省略

發佈了69 篇原創文章 · 獲贊 73 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章