CI整合Smarty
2015-10-26 15:08
393 查看
1.到相应的站点下载smarty模板;
2.将源代码中的libs目录复制到项目的libraries目录下,改名为smarty3.0
3.在项目目录的libraries文件夹内新建文件ci_smarty.php,里面的内容如下:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once(APPPATH . 'libraries/smarty3.0/Smarty.class.php');
class ci_smarty extends Smarty
{
protected $ci;
public function __construct(){
$this->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.测试
控制器中
视图中
2.将源代码中的libs目录复制到项目的libraries目录下,改名为smarty3.0
3.在项目目录的libraries文件夹内新建文件ci_smarty.php,里面的内容如下:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once(APPPATH . 'libraries/smarty3.0/Smarty.class.php');
class ci_smarty extends Smarty
{
protected $ci;
public function __construct(){
$this->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.测试
控制器中
视图中
相关文章推荐
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二十一)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二十一)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二十一)
- spring整合hibernate(注解、xml)applicationContext.xml配置
- 四种强制类型转换的总结
- IOS--JSON解析之JSONKit使用
- yarn关于app max attempt深度解析,针对长服务appmaster平滑重启
- android源码 键盘消息处理机制
- js中的this关键字详解
- http和socket之长连接和短连接区别
- UVA133
- ASp.Net Websocket 环境支持和前端代码实现(二)
- 在JSP中动态生成随机验证码,登录时后台校验验证码,以及如何避免同一个验证码被重复提交爆破密码
- 几句牢骚
- visual studio 2013常用快捷键
- postgresql备份恢复之pg_dump大数据处理
- Java笔记集合之Map
- Google Breakpad 用VS编译windows和android平台的库文件
- Linux点点滴滴之Samba安装与配置
- ARM搭建FTP服务器----FTP arm移植