这两天看了不少 ci与smarty 的整合可是最新稳定版整合!特意整理了
ci 2.1.4 + smarty 3.1.15 配置成功
一、准备文档下载
CodeIgniter_2.1.4、Smarty-3.1.15
二、将Smarty-3.1.15源码包里面的libs文件夹copy到ci的项目目录application下面的libraries文件夹下,并重命名为Smarty-3.1.15
三、application下面的libraries文件夹下,创建文件 Ci_smarty.php
ci = & get_instance(); $this->ci->load->config('smarty');//加载smarty的配置文件 //获取相关的配置项 $this->cache_lifetime = $this->ci->config->item('cache_lifetime'); $this->caching = $this->ci->config->item('caching'); $this->template_dir = $this->ci->config->item('template_dir'); $this->compile_dir = $this->ci->config->item('compile_dir'); $this->cache_dir = $this->ci->config->item('cache_dir'); $this->use_sub_dirs = $this->ci->config->item('use_sub_dirs'); $this->left_delimiter = $this->ci->config->item('left_delimiter'); $this->right_delimiter = $this->ci->config->item('right_delimiter'); }}
四、在config文件下创建smarty.php,copy 以下
';
五、application->config找到autoload.php,修改如下
$autoload['libraries'] = array('Cismarty');
六、在application->core下,新建MY_Controller.php,copy 一下
ci_smarty->assign($key,$val); } public function display($html) { $this->ci_smarty->display($html); }}
到此已经配置成功
下面进行测试
在application->controllers目录下新建welcome.php
assign('test',$test); $this->display('index.html'); }}
在application->views目录下新建index.html
smarty配置测试 <{$test}>
特此感谢:
http://blog.189pt.com/884/#viewSource
http://www.coolphptools.com/codeigniter-smarty
http://www.cainiaoer.com/2013/04/150.html
等
来自:http://blog.newpopline.com/web/ci-2-1-4-smarty-3-1-15.html