这是我的问题,我使用第三方(MX thingy)设置了Codeigniter(第3版),现在我尝试将Smarty(v.3)(模板)与系统集成。这就是我的所作所为:
从smarty.net下载最新的Smarty文件
编辑autoload.php
$autoload['libraries'] = array('smarty');
复制smarty文件并将其粘贴到application / libaries / Smarty
在应用程序/库
上创建了一个文件smarty.php <?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once( APPPATH.'libraries/Smarty/Smarty.class.php' );
class CI_Smarty extends Smarty {
public function __construct()
{
parent::__construct();
$this->compile_dir = APPPATH. "templates_c";
$this->template_dir = VIEWPATH ;
$this->plugins_dir = APPPATH.'libraries/smarty/plugins/';
$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)
{
$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);
}
}
}
皮肤文件夹的文件和文件夹结构如下:
欢迎conteroller中的代码(application \ modules \ welcome \ welcome.php)
class Welcome extends MX_Controller {
function __construct()
{
parent::__construct();
$this->load->model('welcome_model','welcome');
}
public function index()
{
$this->smarty->display('welcome_message.html');
}
}
现在我尝试运行它,但是收到了以下错误消息:
An uncaught Exception was encountered
Type: SmartyException
Message: Unable to load template file 'welcome_message.html'
Filename: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_template.php
Line Number: 139
Backtrace:
File: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_templatebase.php
Line: 192
Function: render
File: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_templatebase.php
Line: 109
Function: _execute
File: C:\xampp\htdocs\cleanci01\application\modules\welcome\Welcome.php
Line: 14
Function: display
File: C:\xampp\htdocs\cleanci01\index.php
Line: 294
Function: require_once
我不知道我怎么会告诉他聪明他应该从&#34; skin / theme / welcome /&#34;而不是在FCPATH(enter image description here)。怎么可能发生这种情况?
非常感谢任何帮助,谢谢你们!