ci 2.1.4 + smarty 3.1.15 配置成功
来源:互联网 发布:百度云老是网络异常 编辑:程序博客网 时间:2024/05/02 03:05
这两天看了不少 ci与smarty 的整合可是最新稳定版整合!特意整理了ci 2.1.4 + smarty 3.1.15 (或 ci 2.2.0 + Smarty-3.1.18等版本都测试通过)配置成功
一、程序下载
下载CodeIgniter2.1.3(以下简称CI)与smarty3.1.12
二、安装CI
解压CI至网站(本次网站测试地址为http://local.ci.com)根目录下面,安装成功后会出现以下内容
三、整合CI与smarty
1、解压smarty压缩包,拷贝libs至ci中application/libraries目录下并改名为smarty
2、在libraries目录下新建smarty.php,添加以下内容
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); require(APPPATH.'libraries/smarty/Smarty.class.php'); class CI_Smarty extends Smarty{ public function __construct(){ parent::__construct(); $this->cache_lifetime = 30*24*3600; //更新周期 $this->caching=false; //是否使用缓存,项目在调试期间,不建议启用缓存 $this->template_dir = APPPATH.'views'; //设置模板目录 $this->compile_dir = APPPATH.'tpl_c'; //设置编译目录 $this->cache_dir = APPPATH.'cache'; //缓存文件夹 $this->use_sub_dirs = false; //子目录变量(是否在缓存文件夹中生成子目录) $this->left_delimiter = '<{';// 用于smarty在html中嵌套显示 $this->right_delimiter = '}>'; } }
注意:__construct()函数里的parent::__construct();一定要加上,不然会出现错误
3、在项目目录下的config文件夹中的autoload.php文件中找到以下代码:
$autoload['libraries'] = array();// 改为$autoload['libraries'] = array('smarty');
截止到现在,CI与smarty整合已经完成,接下来我们来进行测试验证配置是否正确
打开application\controllers目录下的welcome.php将所有代码改为
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Welcome extends CI_Controller { public function index(){ $title='smarty配置成功啦!!!'; $this->smarty->assign('title',$title); $this->smarty->display('index.html'); }}
在view目录下新建index.html文件,写入
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>smarty配置测试</title></head><body> <{$title}></body></html>
在浏览器地址栏里输入http://local.ci.com,即可看到smarty配置成功啦!!!这条信息
0 0
- ci 2.1.4 + smarty 3.1.15 配置成功
- CI配置SMARTY
- CI配置SMARTY
- ci+smarty结合配置方法
- ci+smarty结合配置方法
- ci整合Smarty-3.1.18
- CI+Smarty的配置及引用步骤
- PHP开发工具CI框架下配置smarty模版
- CI 里面整合Smarty
- ci smarty 整合
- ci smarty 整合
- CI继承smarty方法
- CI轻松整合smarty
- CI框架整合smarty模板
- CI 配置
- smarty成功小案例
- 配置Smarty
- smarty配置
- 自定义UISegmentedControl
- .NET压缩与解压控件Xceed Zip for .NET控件详细介绍使用方法及下载
- 境外电商人才培训基地在温大成立
- canvas元素
- 二十四种模式
- ci 2.1.4 + smarty 3.1.15 配置成功
- [14.05.12]今后讨论班的走向
- 佛祖生病了
- 房地产将何去何从?
- 关于脚 ,你知道多少
- 名校和成功没有一毛钱关系
- linux 下面编译安装LAMP环境
- 菜鸟学android——EditText弹出输入法带来的3个问题
- 单播、多播、广播、组播、泛播概念区分