Here is my code:
controllers/
Home.php
PHP Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url_helper');
}
public function index()
{
if ( ! file_exists(APPPATH.'views/themes/default/templates/common/home.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = "Home";
$this->load->view('themes/default/templates/common/header', $data);
$this->load->view('themes/default/templates/common/home', $data);
$this->load->view('themes/default/templates/common/footer', $data);
}
}
views/themes/default/templates/common/
header.php
PHP Code:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<header>
<div class="container"><?php echo $title; ?></div>
</header>
views/themes/default/templates/common/
home.php
PHP Code:
<div class="container">
<h1><?php echo $title; ?></h1>
</div>
views/themes/default/templates/common/
footer.php
PHP Code:
<footer>
<div class="container"><?php echo $title; ?></div>
</footer>
</body></html>
Right now, it shows the text
Home in each section (in
header, in
home, and in
footer).
I want each page shows different titles (
header shows text
Header,
home shows text
Home, and
footer shows text
Footer).
How to achieve it? Thanks.