Hothi Jimit Hothi Jimit - 1 year ago 58
PHP Question

How to customize master template concept in codeigniter 3.0?

I am new in Codeigniter 3.0. So master page concept how used in Codeigniter 3.

I want to make the admin panel master page so I don't rewrite header, footer code. I also want to customize the title.

How to do it?


First I would create something like this below in a controller. You can set your content page in a variable like below and then pass it to your admin template. Like in the example view. Just a example below though.


class Welcome extends CI_Controller {

   public function index() {
      // You should be able to pass data as normal

      $data['title'] = 'Welcome to CodeIgniter';

      $data['template_page'] = 'common/dashboard'; // This dashboard would be name of a view and common name a folder.

      $this->load->view('admin_template', $data);