[eluser]John_Betong[/eluser]
Hi Smalter,
The way I understand MVC is that the Controller's job is to gather data and to distribute the data to the views.
Can you try this approach to your existing code then edit __header.php, __content.php and __footer.php separately.
// Shop: Main Controller
Code:
class Shop extends Controller {
function shop {
parent::Controller();
// Load somes library, plugins or helper
$this->load->helper('blabla');
$this->load->library('blabla');
$this->load->model('my_model');
}
function index() {
$data['htmltitle'] = 'This is my shop!';
$data['list_item'] = $this->my_model->lastentries();
$data['header'] = $this->load->view('__header', $data, TRUE) ;
$data['content'] = $this->load->view('__content_of_my_page', $data, TRUE);
$data['footer'] = $this->load->view('__footer', $data, TRUE);
$output = $this->load->view('homepage', $data, TRUE);
echo $output;
}
}
// Homepage.php: Main view
Code:
<?= $header ?>
<body style='background:#000 none; color:#fff'>
<div style='background:#ff0 none; color:#f00; width:80%; margin:2em auto'>
<?=$content ?>
<?=$footer ?>
</div>
</body>
</html>
__header.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en-GB">
<head>
<title><?= isset($debug) ? $debug : $htmltitle ?></title>
</head>
__content.php
Code:
<h1>Content goes here</h1>
<pre>
<?= print_r($data) ?>
</pre>
__footer.php
Code:
<h1>Footer goes here</h1>
<pre>
<?= print_r($data) ?>
</pre>
Cheers,
John_Betong