Welcome Guest, Not a member yet? Register   Sign In
How to setup smarty 3.1.30 to codeigniter 3.0.4
#1

Hi I have a problem with integrating the smarty into my codeigniter.

Here's what I did:

1. Autoloader.php (application\config\Autoloader.php)
Code:
$autoload['libraries'] = array('template');

2. Template.php (application\libraries\Template.php)
Code:
include_once(APPPATH.'libraries/smarty/Smarty.class.php');
class template extends Smarty{
    function __construct()
    {
        $this->compile_dir = _CACHE_FOLDER_.'compile'; // _CACHE_FOLDER_ = application/cache/
        $this->template_dir = _SKIN_URL_;  // _SKIN_URL_ = skin/
        $this->plugins_dir = APPPATH.'libraries/smarty/plugins/'; // APPPATH = application/
        $this->error_reporting = E_ALL & ~E_NOTICE;
        log_message('debug', "Smarty Class Initialized");
    }
}

3. created folder "smarty" under libraries
PATH: application > libraries >
- smarty (folder)
- index (html forbiden)
- Template (php)

4. copied and pasted the files inside "smarty" folder
PATH: application > libraries > smarty
- plugins (folder)
- sysplugins (folder)
- Autoloader (php - from smarty master file)
- debug (tpl - from smarty master file)
- Smarty.class (php - from smarty master file)
- SmartyBC.class (php - from smarty master file)

5. The code only in contactus controller is this
Code:
class Contactus extends CI_Controller {
    public function index()
    {
        $this->load->view('contactus');
    }
    public function test()
    {
        $this->load->view('test');
    }
}


6. Tried to go to a page (http://localhost/citest04/contactus/test) but I still get this error message

Fatal error: Cannot redeclare class template in C:\xampp\htdocs\citest04\application\libraries\Template.php on line 23
Reply




Theme © iAndrew 2016 - Forum software by © MyBB