[eluser]John_Betong[/eluser]
I prefer to use the Loader Class in the Controllers. The CodeIgniter Help file has details.
controller/home.php
Code:
...
function index{$data=array()) {
// ESSENTIAL to setup variables here which are passed to the sub-sections.
$data['title'] = 'Johns-Jokes.com';
// My convention: All parts of a web-page are prefixed with '_'
$data['doctype'] = $this->load->view('_doctype', $data, TRUE); // TRUE ensures item is loaded into memory
$data['header'] = $this->load->view('_header', $data, TRUE);
$data['content'] = $this->load->view('_homepage', $data, TRUE);
$data['footer'] = $this->load->view('_footer', $data, TRUE);
$output = $this->load->view('home', $data, TRUE);
echo $output;
}//endfunc index
...
...
view/home.php
Code:
<?= $doctype ?>
<head>
<?= $header ?>
<style type="text/css">
div {border:dotted solid 0px #f00} /* for debugging */
</style>
</head>
<body>
<div id='container'><?php /* width=856, */ ?>
<?= $title ?>
<div id='box_center'>
<?= $content ?>
</div>
<div id='footer'>
<?=$footer?>
</div>
</div><?php /* container */ ?>
</body>
</html>
This technique maybe long winded but I find it easy to go read the code, debug and to modify the view files to ensure they have no Html validation errors.