codein 发表于 2016-1-15 15:50:33

Ci 3.0 成功安装smarty 使用assign 为什么页面取不到值


Cismarty.php建在application/libraries/

<?phpif (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* Smarty Class
*
* @package    CodeIgniter
* @subpackageLibraries
* @categorySmarty
* @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}
就是取不出值

这是什么情况





codein 发表于 2016-1-18 09:28:32

有没有人3.0安装smarty成功的?

codein 发表于 2016-1-18 11:19:45

$data['time'] = $log_time;
$this->cismarty->assign("datas",$data);
换成自动加载
$this->assign("datas",$data);

页面年接把标签输出了
{datas.time}
{{datas.time}}
{{datas['time']}}

codein 发表于 2016-1-19 14:58:08

what?没人遇到过?
页: [1]
查看完整版本: Ci 3.0 成功安装smarty 使用assign 为什么页面取不到值