[eluser]CroNiX[/eluser]
I make a library that puts the header and footer automatically, which I autoload. Then in my controllers I just send my "content" view to the library which outputs the header, footer, login modules, widgets, etc., which are generated dynamically. There are several ways to achieve this. I want my controllers to ONLY deal with the functionality of those controllers.
Simple version of the library:
Code:
class Template
{
function Template()
{
$this->CI =& get_instance();
}
function make_front($page_title, $page_h1, $meta_keywords, $meta_description, $content)
{
//assemble the header
$head['page_title'] = $page_title;
$head['page_h1'] = $page_h1;
$head['meta_description'] = $meta_description;
$head['meta_keywords'] = $meta_keywords;
$header = $this->CI->load->view('frontend/header', $head, TRUE);
//assemble footer
$foot['states'] = $this->get_states();
$footer = $this->CI->load->view('frontend/footer', $foot, TRUE);
$out = $header . $content . $footer;
$this->CI->output->set_output($out);
}
}
Then in my controller, I just pass the view being generated by that controller to the template, which tacks on the header and footer:
Code:
$content = $this->load->view('my_content', $data, TRUE);
$this->template->make_front('page title', 'page H1', 'keywords', 'description', $content);