用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1304|回复: 3
收起左侧

[版本 3.x] Ci 3.0 成功安装smarty 使用assign 为什么页面取不到值

[复制链接]
发表于 2016-1-15 15:50:33 | 显示全部楼层 |阅读模式
[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}
就是取不出值

这是什么情况





 楼主| 发表于 2016-1-18 09:28:32 | 显示全部楼层
有没有人3.0安装smarty成功的?
 楼主| 发表于 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']}}

 楼主| 发表于 2016-1-19 14:58:08 | 显示全部楼层
what?没人遇到过?

本版积分规则