0
votes

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?

1
1) I've tried to give to your post a better form, but it seems still unclear to me. It is important to try to use clear sentences, and try to follow the style of the English communication. Give also many details: explain, what you tried, what problems you found, what is not working. People here can see only what you write, they don't see what is on your computer. 2) It is not a problem if your English is not very good, the problem is if people doesn't understand what you ask. - peterh
what not understand ?? its simple how make layout - Hothi Jimit
header , footer , sidebar , content i want this fout layout ok ?? - Hothi Jimit
i want customize like in <title></title> not same all page - Hothi Jimit

1 Answers

1
votes

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. also auto load url helper.

<?php

class Welcome extends CI_Controller {

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

      $data['title'] = 'Welcome to CodeIgniter'; // You can change the title on every controller you create.

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

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

}

Example 2 Controller

<?php

class Dashboard extends CI_Controller {

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

      $data['title'] = 'Dashboard'; // You can change the title on every controller you create.

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

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

}

Views > template.php

<?php

$this->load->view('common/header');

$this->load->view($template_page);

$this->load->view('common/footer');

?>

Header views > common > header.php

<!DOCTYPE html>
<html>
<head>
    // meta tags
    <title><?php echo $title;?></title>
    // css links
    // other js links
</head>

<body>

Content lets say dashboard views > common > dashboard.php

 <h1>Hello World</h1>

Footer views > common > footer.php

// bootstrap scripts.
</body>
</html>