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?
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. 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>