|
[code=PHP][/code]
Cismarty.php建在application/libraries/
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Smarty Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Smarty
* @author Kepler Gelotte
* @link http://www.coolphptools.com/codeigniter-smarty
*/
// echo BASEPATH;
// echo "<br>";
// echo APPPATH;exit;
require_once APPPATH.'third_party/smarty/libs/Smarty.class.php';
class Cismarty extends Smarty {
protected $ci;
public function __construct(){
parent::__construct();
$this->ci = & get_instance();
$this->caching = false;
$this->setTemplateDir(APPPATH . 'smartyinfo/templates'); //设定所有模板文件都需要放置的目录地址。
$this->setConfigDir(APPPATH . 'smartyinfo/configs'); //设定用于存放模板特殊配置文件的目录,
$this->setCacheDir(APPPATH . 'smartyinfo/cache'); //在启动缓存特性的情况下,这个属性所指定的目录中放置Smarty缓存的所有模板
$this->setPluginsDir(APPPATH . 'smartyinfo/plugins'); //插件目录
$this->setCompileDir(APPPATH . 'smartyinfo/templates_c'); //设定Smarty编译过的所有模板文件的存放目录地址
}
}
目前还在测试,所以这两个是暂时放在了CI本身的system/core/controller.php里
public function assign($key,$val) {
$this->cismarty->assign($key,$val);
}
public function display($html) {
$this->cismarty->display($html);
}
自动加载
$autoload['libraries'] = array("database","Ajax","Cismarty");
控制器中
$this->assign("datas",$data);
页面
{$datas['time']}
{$datas.time}
就是取不出值
这是什么情况
|
|