我按照本手册设置了集成的smarty和codeigniter环境
http://www.coolphptools.com/codeigniter-smarty
但我想使用smarty设置多主题。我知道它必须对我的库smarty.php
这是我的smarty.php
文件
<?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
*/
require_once( 'libs/Smarty-3.1.16/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");
}
/**
* Parse a template using the Smarty engine
*
* This is a convenience method that combines assign() and
* display() into one step.
*
* Values to assign are passed in an associative array of
* name => value pairs.
*
* If the output is to be returned as a string to the caller
* instead of being output, pass true as the third parameter.
*
* @access public
* @param string
* @param array
* @param bool
* @return string
*/
function view($template, $data = array(), $return = FALSE)
{
foreach ($data as $key => $val)
{
$this->assign($key, $val);
}
if ($return == FALSE)
{
$CI =& get_instance();
if (method_exists( $CI->output, 'set_output' ))
{
$CI->output->set_output( $this->fetch($template) );
}
else
{
$CI->output->final_output = $this->fetch($template);
}
return;
}
else
{
return $this->fetch($template);
}
}
}
// END Smarty Class
我创建的用于集成smarty和codeigniter,如手册中所述。
但我不知道该文件中要编辑什么来启用多主题..
我想知道的。
smarty.php
文件中编辑什么,这样多主题应该可以正常工作。我曾在codeigntier工作过一段时间,但聪明才对我来说很新。
答案 0 :(得分:2)
问题解决了,感谢github上的某个人......
https://github.com/Vheissu/Ci-Smarty
不得不通过代码,因为没有关于如何实现它的文档,我花了一些时间来理解。