CodeIgniter2.0.1和smarty3.0.7无缝整合,新手必修技打包下载
CodeIgniter2.0.1和smarty3.0.7无缝整合都是全新版本 和 以往的插件方法不同是很好的无缝整合解释:application\libraries\Smarty.php
<?phpif (!defined('BASEPATH')) exit('No direct script access allowed');
require_once( BASEPATH.'libs/smarty/libs/Smarty.class.php' );
class CI_Smarty extends Smarty {
function CI_Smarty()
{
parent::Smarty();
$this->compile_dir = APPPATH . "views/templates_c";
$this->template_dir = APPPATH . "views/templates";
$this->assign( 'APPPATH', APPPATH );
$this->assign( 'BASEPATH', BASEPATH );
log_message('debug', "Smarty Class Initialized");
}
function __construct()
{
parent::__construct();
$this->compile_dir = APPPATH . "views/templates_c";
$this->template_dir = APPPATH . "views/templates";
$this->assign( 'APPPATH', APPPATH );
$this->assign( 'BASEPATH', BASEPATH );
// Assign CodeIgniter object by reference to CI
if ( method_exists( $this, 'assignByRef') )
{
$ci =& get_instance();
$this->assignByRef("ci", $ci);
}
log_message('debug', "Smarty Class Initialized");
}
function view($template, $data = array(), $return = FALSE)
{
foreach ($data as $key => $val)
{
$this->assign($key, $val);
}
if ($return == FALSE)
{
//注意这里使用了get_instance();但是在output类中final_output是受保护的,所以需要修改修饰符!
$CI =& get_instance();
$CI->output->final_output = $this->fetch($template);
return;
}
else
{
return $this->fetch($template);
}
}
}
占位,好好看看 看样子不错, 不过不是很喜欢这种破坏结构的 好吧,标记一下,做项目刚好需要用到! 收藏...留著以後使用. mark ,很久没解决的问题,因为看得都是旧版本的指南。以后再用……多谢 感觉为了高效,还是放弃模板引擎好一点。 不是有内置模板么? 还用smarty啊,我已经抛弃了smarty这种东西,太浪费资源了。 明显是用新手来骗人,新手哪有这样入门的呢?
页:
[1]
2