[eluser]jedd[/eluser]
Okay .. well, remember that this is just one way of doing things. Some people approach the problem quite differently - using a templating system, or calling views from within views. I haven't played with the different template systems much, and I suspect my background (non-MVC, non-OOP) makes me stick with my current way. I also don't like calling views from within views, as I find the indirection unnecessarily confusing and harder to a) design, and b) trouble-shoot. Others, as I say, swear by this approach.
I mention this simply because it's like anything in IT - whichever path you go down first, is likely to be the way you'll do it forever.
Having said that ... your controller code:
Quote:Code:
function index()
{
$this->load->model('example');
$data['query'] = $this->example->products();
$this->load->view('header');
$this->load->view('nav');
$this->load->view('content', $data, TRUE);
$this->load->view('footer');
}
Okay, so the differences in my approach are basically:
a) I call my header, nav and footer equivalents in [url="/wiki/MY_Controller"]MY_Controller[/url] (this is well documented in the CI User Guide - have a re-read of that section),
b) when I call my header/nav/footer views, I return the value into a variable (
$this->data['top_bar_view'], etc) so that it will be visible in all my Controllers, and more importantly, in every view that I pass
$this->data to (ie. all of them)
c) in a vanilla controller, I will simply generate my main content view using whatever custom load->view('controllername/thing') call, also loading that with the TRUE third flag, sending the output to
$this->data['main_content_view'] and then I'll load my default view - the one that pretty much every page is made from, and that contains very little other than DIVs and echo's of the above generated views. I posted my default.php view file earlier in this thread.
Does that make it clearer?
If you are really stuck, PM me with an email address and I can zap you a tarball of my current far-from-finished but slightly enlightening project files with this stuff in it.