The template mechanism of smarty is very powerful. generally, CI does not need to integrate other template tags, because PHP itself is a label and is easy to use. Codeigniter integration smarty tutorial (I use the latest version): Step 1: Download codeign
The template mechanism of smarty is very powerful. generally, CI does not need to integrate other template tags, because PHP itself is a label and is easy to use. Codeigniter integration smarty tutorial (I use the latest version) as follows:
Step 1: Download the latest codeigniter: http://codeigniter.org.cn/downloads
Step 2: Download the smarty latest version: http://www.smarty.net/download
Step 3:
Configuration steps:
(1) copy the smarty to application/libraries, and create the templates, templates_c, config, and cache directories under the root directory. The structure is as follows:
(2) add a new entry FILE: define ('root', dirname (_ FILE __));
(3) Create CI_Smarty.php under libraries
$ Value) {$ this-> $ key = $ value;} else {// ROOT is Codeigniter in the entry file index. root directory of the web application defined by php $ this-> template_dir = $ template_dir? $ Template_dir: ROOT. '/templates'; $ this-> compile_dir = $ compile_dir? $ Compile_dir: ROOT. '/templates_c'; $ this-> config_dir = $ config_dir? $ Config_dir: ROOT. '/config'; $ this-> cache_dir = $ cache_dir? $ Cache_dir: ROOT. '/cache ';}}}
Use in controller:
load->library('CI_Smarty'); } public function test() { $this->ci_smarty->assign('test', 'smarty'); $this->ci_smarty->display('test.tpl'); }}/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */
Create a test. tpl template:
This is a {$ test} test
Test successful!