<?php
if(!defined('BASEPATH')) EXIT('No direct script asscess allowed');
require APPPATH . 'libraries/smarty/Smarty.class.php';
class Cismarty extends Smarty {
protected $ci;
protected $complie_dir;
protected $template_ext;
public function__construct(){
parent::__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->template_ext = $this->ci->config->item('template_ext');
$this->caching = $this->ci->config->item('caching');
$this->cache_lifetime = $this->ci->config->item('lefttime');
$this->left_delimiter = '<{';
$this->right_delimiter = '}>';
if(function_exists('site_url')) {
// URL helper required
$this->assign('site_url', site_url()); // so we can get the full path to CI easily
}
$this->assign('elapsed_time', $this->ci->benchmark->elapsed_time('total_execution_time_start', 'total_execution_time_end'));
$this->assign('memory_usage', ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage() / 1024 / 1024, 2) . 'MB');
}
} Fatal error: Call to a member function createTemplate() on a non-object in D:\ci\application\libraries\Smarty\sysplugins\smarty_internal_templatebase.php on line 48
我配置的报这个错 是怎么回事哦? 跟楼上一样,配置smarty3就出这个问题了,我记得是smarty3后不允许继承,不是知道是不是这个原因影响,请楼主解惑! 赞一个,不错。可以使用。这样就大大减少了代码量{:soso_e179:}
FCPATH是什么? sxd_11 发表于 2014-8-2 18:52
**** 作者被禁止或删除 内容自动屏蔽 ****
你好啊,为什么我按照了你的配置,还是出现你说的那个错误呢?谢谢
An Error Was Encountered
Unable to load the requested class: cismarty
这根本就无法加载啊。
纠正两个错误:适应smarty3
<?php
if(!defined('BASEPATH')) EXIT('No direct script asscess allowed');
require_once( APPPATH . 'libraries/smarty/libs/Smarty.class.php' );
class Cismarty extends Smarty {
protected $ci;
protected $complie_dir;
protected $template_ext;
public function__construct(){
parent::__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');
$this->left_delimiter = '{';
$this->right_delimiter = '}';
}
}
在楼主的代码中加入 protected $complie_dir;
protected $template_ext;
parent::__construct();
即可。 好的技术贴帮人, 但一点小错误也会害人.19楼纠正的是没问题, 但问题的根本原因, 在于配置项的小细节错误.不应该是"complie_dir" ,而是compile_dir....
页:
1
[2]