I'm looking for a "good practique" for templating in codeigniter (actual version) (sorry for my bad english). All info I have founded is really old and has many options to do the same, but I can't understad which one of those methods are better of if there is a standar way for doing that. I'm gonna describe the best tree methods I have found in mi opinion and the idea is to know which one is a better choice (cleanest, simplest, and codeigniter patron oriented).
Method 1: extendidng controller class: I think that this method is easy to implement and very usefull, but it means to change all controllers logic
PHP Code:
class MY_Controller extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function loadPage($contentView = false, $data = array()){
if(!$contentView) $contentView = 'home';
$this->load->view('header', $data);
$this->load->view($contentView, $data);
$this->load->view('footer', $data);
}
}
and for the controllers do something like:
PHP Code:
class Pages extends MY_Controller {
}
Method 2: doing the same but with a loader (I'm not sure about how to do this)
Method 3: doing the same with a library
(I'm not sure about how to do this)
Method 4: Doing a template view that loads the partials
Other methods that I don't know...
The idea is to have many templates, for example with top nav bar, another one with lef side menu and load the template in the contreoller passing expecifically the view who need to insert in the template (and it's data array).
Are one of these methods recommended? or any better way for doing this?