您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

CI整合Smarty

2024/6/26 4:26:10发布34次查看
1.到相应的站点下载smarty模板;
2.将源代码中的libs目录复制到项目的libraries目录下,改名为smarty3.0
3.在项目目录的libraries文件夹内新建文件ci_smarty.php,里面的内容如下:
ci = & get_instance();
        $this->ci->load->config('smarty');//加载smarty的配置文件
        //获取相关的配置项
        $this->template_dir   = $this->ci->config->item('template_dir');
        $this->complie_dir    = $this->ci->config->item('compile_dir');
        $this->cache_dir      = $this->ci->config->item('cache_dir');
        $this->config_dir     = $this->ci->config->item('config_dir');
        $this->template_ext   = $this->ci->config->item('template_ext');
        $this->caching        = $this->ci->config->item('caching');
        $this->cache_lifetime = $this->ci->config->item('lefttime');
    }
}
4.在项目目录的config文件夹内新建文件smarty.php文件,里面的内容如下:
5.在入口文件所在目录新建文件夹templates_c
6.在项目的配置文件夹下,autoload.php文件中加入
$autoload['libraries'] = array('ci_smarty');
7.在项目目录的core文件夹中新建文件my_controller.php 内容如下: // 扩展核心控制类
8.测试
控制器中
视图中
以上就介绍了ci整合smarty,包括了require方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product