[eluser]CroNiX[/eluser]
I created a simple library that assembles the login status, header, menu, footer, etc. All I do is pass it the page title and content created from my current controller to the template library and it does the rest.
In my controller I do my stuff and...
Code:
//used to hold the data that will go to the content view
$data = array();
//set the page title for the template
$page_title = 'page title';
//create the view for this method in this controller
$page_content = $this->load->view('view_file', $data, TRUE);
//now send them to the template for final output.
$this->template->make_page($page_title, $page_content);
Then in template::make_page(), something like:
Code:
public function make_page($title = '', $content = '')
{
//pass the title to the header and output header view
$header = $this->CI->load->view('templates/header', array('title' => $title), TRUE);
//find out if the user is logged in or not.
//if so it will display their profile links, etc. If not, it shows login form
$login_status = $this->CI->auth->current_user();
//get menu from database and pass to menu view to assemble
$data['menu'] = $this->CI->template_model->get_menu($login_status);
$menu = $this->CI->load->view('templates/menu', $data, TRUE);
//get footer
$footer = $this->CI->load->view('templates/footer', array(), TRUE);
//assemble and set final output (used so can use caching)
$this->CI->output->set_output($header . $menu . $content . $footer);
}
Then you can have different methods for pages with sidebars, admin, etc. Hope that helps.