I usually use MY_Controller and load the view like so (example only)(if anybody has some thoughts about my way, please, make me smarter
):
Code:
class MY_Controller extends CI_Controller
{
/*
* Everything else you need
*/
protected function render($views, $data = FALSE, $css = FALSE, $js = FALSE)
{
//get BASE css files, append new if needed
$head['css'] = $this -> addCss($css);
//metadata
$head['metaData'] = $this -> metaData;
//get BASE scripts, append new if needed
$addJs['js'] = $this -> addJs($js);
$this -> load -> view('page/head_view', $head);
$this -> load -> view('page/header_view');
$this -> load -> view('page/sidebar_view');
if ($views === FALSE)
{
$this -> load -> view('page/content_view', $data);
}
else
{
if (is_array($views))
{
foreach ($views as $view)
{
$this -> load -> view($view, $data);
}
}
else
{
$this -> load -> view($views, $data);
}
}
$this -> load -> view('page/content_end_view');
$this -> load -> view('page/footer_view', $addJs);
}
}
Then in Some_controller:
Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Index extends MY_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$data = $this -> getDataFromSomewhere();
$this -> render('', $data);
//Or if I want a special "content" view
$this -> render('name_of_view',$data);
}
}
Thank you for the #EOF tip.
*Edit -> BB code tags...