|
CodeIgniter2.0.1和smarty3.0.7无缝整合都是全新版本 和 以往的插件方法不同是很好的无缝整合
解释:application\libraries\Smarty.php
PHP复制代码
<?php if (!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);
}
}
}
复制代码
ci2.0.1 smarty3.0.7无缝整合,新手必修技.zip
(616.7 KB, 下载次数: 391)
|
评分
-
查看全部评分
|