以下為引用的內容: smarty [staging : production] smarty.class_path = "Smarty/Smarty.class.php" smarty.left_delimiter = "<*" smarty.right_delimiter = "*>" smarty.template_dir = "template" smarty.compile_dir = "compile" smarty.cache_dir = "cache" smarty.cache_lifetime = 600 smarty.caching = 1 |
打開Bootstrap.php文件,添加一個函數用于初始化Smarty
以下為引用的內容: _initView public function _initView(){ $config = new Zend_Config_Ini(CONFIG_FILE_PATH, 'staging'); require_once $config->smarty->class_path; $smarty = new Smarty(); $smarty->left_delimiter = $config->smarty->left_delimiter; $smarty->right_delimiter = $config->smarty->right_delimiter; $smarty->template_dir = $config->smarty->template_dir; $smarty->compile_dir = $config->smarty->compile_dir; $smarty->cache_dir = $config->smarty->cache_dir; $smarty->cache_lifetime = $config->smarty->cache_lifetime; $smarty->caching = $config->smarty->caching; Zend_Registry::set('smarty', $smarty); } |
到此Smarty就整合好了。再貼一點點使用的代碼吧
以下為引用的內容: $this->smarty = Zend_Registry::get('smarty'); $this->smarty->assign('bloguser', $this->bloguser); $this->smarty->display($template); |
網上有個整合的方法是把Smarty當成Zend Framework的一個插件,我覺得挺麻煩的,本人比較懶,還是喜歡現在這樣子運用。
轉自:http://www.cnblogs.com/reallypride/