[eluser]Rey Philip Regis[/eluser]
Well....I think what you need is to create a master template and in that master template you specify the parts of your page including the header, content and the footer. Ill show you a sample on how to do it. This is what we call loading a view within a view.
Code:
Controller:
Sample.php
class Sample extends Controller
{
function Sample()
{
parent::Controller();
// need this to use base_url() in the template.php
$this->load->helper('url');
}
function index()
{
$data['title'] = 'Sample Template';
$data['header'] = 'header_page'; // name of the view
$data['content'] = 'main_page'; // name of the view
$data['footer'] = 'footer_page'; // name of the view
$this->load->view('template', $data);
}
}
template.php
<html>
<head>
<title><?php echo $title; ?></title>
<link type="text/css" rel="stylesheet" href="<?php echo base_url().'system/css/default.css'; ?>" />
</head>
<body>
<div id="wrapper">
<div id="header">
<?php // dynamic loading of header just specify the $header in the controller
$this->load->view($header);
?>
</div>
<div id="content">
<?php // dynamic loading of content just specify the $content in the controller
$this->load->view($content);
?>
</div>
<div id="footer">
<?php // dynamic loading of footer just specify the $footer in the controller
$this->load->view($footer);
?>
</div>
</div>
</body>
</html>
main_page.php
<h1>This is the dynamic content (main page) of the page.....</h1>
header.php
<h1>Welcome to the website</h1>
footer.php
<h1>Copyright 2008</h1>
Hope this helps!