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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章