Smarty with CodeIgniter

Smarty with CodeIgniter

Smarty with CodeIgniter

Tudip

24 June 2016

We have been using CodeIgniter with Smarty for quite a few projects. Getting the Smarty to work with CodeIgniter is not straight forward. It has its own set of quirks. The steps below explain how to set up CI to work with Smarty on Windows and Linux (tested on Ubuntu but should work on other flavors too) machines.

  • Requirements
    1. First download CI here
    2. Next download Smarty template here
    3. And lastly download application folder from our website
  • Installation
    1. Unzip CI into the root folder.
    2. Next, unzip smarty into CI’s application/third_party folder.
    3. And then unzip the downloaded application folder and copy it into CI’s application folder.
    4. Change autoload.php from config folder for autoload of parser and smarty library: $autoload[‘libraries’] = array(‘parser’, ‘smarty’)
    5. Make directory application/cache/smarty/compiled, remember to give write permission for created directory.
    6. Make .tpl pages inside views directory. Ex: welcome.tpl
    7. From controller call $this->parser->parse(‘welcome.tpl’, $data);

Now you should be able to view Smarty tpl files 🙂

search

Blog Categories

Request a quote