I'm using a CI class which extends the core CI_LOADER allowing me to load a template within a template:
$this->load->view('wrapper','category',$data);
This loads a template of category in to the master template wrapper.
This means in the controllers I have to make sure I always populate any data that needs to be fed in to the wrapper view as well as the inner view. So all of my classes include methods which are needed to pull in stuff like the dynamic navigation and categories which are displayed in the wrapper view...then in my controllers that are generating the inner view I have to call these methods and assign them as output.
My controllers can end up looking like this:
public function product_listing($store,$category,$product_slug) {
//These are all needed to populate the wrapper view
$data['categories'] = $this->get_categories();
$data['navigation'] = $this->navigation();
$data['cart'] = $this->get_cart();
$data['store'] = $store;
//Then this is needed for the inner view
$data['products'] = $this->model_products>get_product($store,$category,$product_slug);
$data['title'] = $data['products'][0]->product_name;
}
My question is, is there any way to load this stuff in some sort of wrapper class to avoid polluting each of my classes with methods (and calls to these methods from within other methods as above) that are needed for the wrapper view.