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.
- First download CI here
- Next download Smarty template here
- And lastly download application folder from our website
- Unzip CI into the root folder.
- Next, unzip smarty into CI’s application/third_party folder.
- And then unzip the downloaded application folder and copy it into CI’s application folder.
- Change autoload.php from config folder for autoload of parser and smarty library: $autoload[‘libraries’] = array(‘parser’, ‘smarty’)
- Make directory application/cache/smarty/compiled, remember to give write permission for created directory.
- Make .tpl pages inside views directory. Ex: welcome.tpl
- From controller call $this->parser->parse(‘welcome.tpl’, $data);
Now you should be able to view Smarty tpl files 🙂