[eluser]BrianDHall[/eluser]
Personally I use individual views for things relating to my basic site template, like header, footer, leftnav, rightnav. I initialize these into properties I set in my controller in the constructor, such as:
Code:
class DefaultController extends Controller {
var $header, $leftnav, $content, $rightnav, $footer, data = '';
function DefaultController()
{
parent::Controller();
$this->data['header'] = &$this->header;
$this->data['leftnav'] = &$this->leftnav;
$this->data['content'] = &$this->content;
$this->data['rightnav'] = &$this->rightnav;
$this->data['footer'] = &$this->footer;
$this->header = $this->load->view('header', $this->data, true);
$this->leftnav = $this->load->view('leftnav', $this->data, true);
$this->rightnav = $this->load->view('rightnav', $this->data, true);
$this->footer = $this->load->view('footer', $this->data, true);
}
}
Then in my pages I load their specific view, such as 'frontpage', load it into $this->content, and then load the default view which prints out the values for the predefined elements in their proper HTML placements.
I further organize by naming views with '_form' that are just forms, and then I stick '_success' and '_failure' as appropriate so I know what they are supposed to be used for - as needed, of course.
I like the flexibility and automation it provides, and it allows new pages to be built by just using 2 lines of code:
Code:
function index()
{
$this->content = $this->load->view('frontpage', $this->data, true);
$this->load->view('defaultview', $this->data);
}
And if I need 1 function for some reason to totally change (or just add to) any of the navigation or page elements its easy and lightweight.
And it works, which I like the most of all