问题
Here's what I did:
- Downloaded and unzipped CI
- Downloaded and unzipped Smarty in
/application/libraries/Smarty-3.1.4
- Saved
https://github.com/kzhiwei/codeigniter-smarty/blob/master/application/libraries/Smartylib.php
to/application/libraries/Smartylib.php
(also fixed line 2 to point to the correct folder) - Added
Smartylib
in autoload libraries - Created a
test.tpl
and called it from the controller:$this->Smartylib->display('test.tpl');
Now, I'm getting the following error:
Fatal error: Call to a member function createTemplate() on a non-object in C:\wamp\www\myapp\application\libraries\Smarty-3.1.4\libs\sysplugins\smarty_internal_templatebase.php on line 47
Any ideas what is wrong?
回答1:
Library references are case sensitive:
$this->load->library('smartylib');
$this->smartylib->display('test.tpl');
来源:https://stackoverflow.com/questions/7883300/codeigniter-smarty-error