10-15-2008, 10:31 AM
[eluser]darrenm[/eluser]
I use a slightly different approach. I abstract my view loading into a custom library called Page.
This lib has functions for adding and removing style sheets and javascripts and a few other things. It then has a function called render_page() which loads all the various views required
you can then call this from your controller like so:
This keeps all $data in one array and has lots of scope for handling other common tasks (I use it in conjunction with a navigation generator for example).
Hope that helps
I use a slightly different approach. I abstract my view loading into a custom library called Page.
This lib has functions for adding and removing style sheets and javascripts and a few other things. It then has a function called render_page() which loads all the various views required
Code:
function render_page($view,$data) {
$this->CI->load->view('_header',$data);
$this->CI->load->view($view,$data);
$this->CI->load->view('_footer',$data);
}
you can then call this from your controller like so:
Code:
$data['docTitle'] = 'My document title';
$data['content'] = 'Page content';
$data['something'] = 'else';
$this->page->render_page('my_view_file',$data);
This keeps all $data in one array and has lots of scope for handling other common tasks (I use it in conjunction with a navigation generator for example).
Hope that helps