Templates in CodeIgniter
9 January 2009 | Category: Code | Tags: Code, CodeIgniter, PHP, Projects | 1 Comment
One of the most annoying stuff for CodeIgniter developers is to include a header/footer/etc part in each and every view. CodeIgniter out of the box does not include template support (in the sence of a Joomla template or Wordpress theme). I have created a small library to assist you in using “templates” in CodeIgniter.
Download
Download Templates for CodeIgniter 0.1
How to use
1) First copy the file MY_loader.php to your application/libraries folder.
2) Check the example folder to see how a template should look like.
3) Simply do:
$this->load->template('template_name', $data); $this->load->view('view_name', $data);
The template loading is done in pretty much the same way as the views loading. However please read the comments inside the MY_loader.php file. It takes one minute and you’ll get the whole picture about how you can pass $data arrays containing variables.
RSS feed
Twitter
Delicious
Facebook
Last.fm