Search code examples
phpcodeigniter-2

How to integrate templates into Codeigniter?


I am new to Codeigniter. How do you integrate templates? Something like:

header_template.php etc...

Right now I do it like this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Page extends CI_Controller {

    public function index()
    {   
        $this->load->view('head_template.php');
        $this->load->view('header_template.php');
        $this->load->view('navigation_template.php');
        $this->load->view('page_view.php');
        $this->load->view('footer_template.php');

    }
}

While this is fine, there has to be a better way. I have to include this into every controller, which is a little bit intimidating.

I know about the template engine, but it's not what I am looking for. Plus, it says it's slow in the Codeigniter documentation.


Solution

  • Use this temple engine very easy and good documentation too

    Check this git repo for sample application with CI and templete engine

    github.com/mrsrinivas/ci_template