[eluser]TuxLyn[/eluser]
Here is simple model function to load views easier.
Basic page() function
This function can be called with or without $data.
$this->mymodel->page('welcome');
$this->mymodel->page('welcome', $data);
Model:
Code:
function page($page, $data = NULL) {
$this->load->view('header', $data);
$this->load->view($page, $data);
$this->load->view('footer', $data);
} //page()
Controller Example:
Code:
public function index() {
$data['test'] = 'testing';
$this->mymodel->page('welcome', $data);
}
page() function with vars and titles
This function can be called with or without $data / titles.
$this->mymodel->page('welcome', 'page title here');
$this->mymodel->page('welcome', 'page title here', $data);
Also, you can use "vars" and $base, $page, $title variables
in any pages you use $this->mymodel->page() function on.
Model:
Code:
function page($page, $title, $data = NULL) {
$data['base'] = base_url();
$data['page'] = $page;
$data['title'] = $title;
$this->load->vars(array(
'test' => $this->mymodel->test();
));
$this->load->view('header', $data);
$this->load->view($page, $data);
$this->load->view('footer', $data);
} //page()