關於smarty的自定義函數使用

{strip}.....{/strip}去除包含內容部分的空白和回車html

模板文件:註釋 換行  回車,這樣編譯模板文件看起來可讀性好數組

編譯文件:模板文件的換行,和回車在文件中也會體現出來,能夠使用此標籤將其取出app

{debug} 調試,會給咱們輸出一個和smarty變量信息有關係的控制檯fetch

{eval}...{/eval} 輸出變量信息{eval var=complain}  或  {eval var=complain assign="goldstone"}spa

將complain保存到goldstone變量中   在其餘地方使用時{$goldstone}debug

{fetch}。。。{/fetch}得到文件內容
調試

{fetch  file=」http://www.baidu.com」}htm

{cycle}....{/cycle} 交替出現   {cycle values='red,blue,green'}對象

{html_image}
圖片

生成圖片標籤

file

width

height

herf  圖片超連接    a標籤也會顯示

{html_table}表格標籤

smarty屬性  $comolie_check=true 


經常使用方法

1 append  assign的區別:

        append:把變量放入到smarty對象的數組裏邊

        assign: 把變量放入到smarty對象的變量裏邊

2 assignByRef()

3 clearAllAssign() 清楚全部的assign變量信息

4 clearAssign() 清楚指定的assign變量信息

5 configload() 引入配置變量

    a{config_load file="site.conf" section="newyear"}

    b $smarty->configLoad("site.conf",'newyear');

6 clearConfig()清楚配置變量

7 display()戰士模板信息

8 fetch() 得到模板信息

9 display() =echo fetch

10 templateExists()檢查編譯文件是否存在

11 clearCompiledTemplate() display以前調用


總結:

    smarty雨已有的項目結合

    ①本身項目的autoload與smarty的autoload作兼容處理

    ②具體使用

    ③在父類控制器實例化smarty

相關文章
相關標籤/搜索