php - Nesting controllers in Code Igniter -


i'm using ci class extends core ci_loader allowing me load template within template:

$this->load->view('wrapper','category',$data); 

this loads template of category in master template wrapper.

this means in controllers have make sure populate data needs fed in wrapper view inner view. of classes include methods needed pull in stuff dynamic navigation , categories displayed in wrapper view...then in controllers generating inner view have call these methods , assign them output.

my controllers can end looking this:

public function product_listing($store,$category,$product_slug) {     //these needed populate wrapper view     $data['categories'] = $this->get_categories();     $data['navigation'] = $this->navigation();     $data['cart'] = $this->get_cart();     $data['store'] = $store;     //then needed inner view             $data['products'] = $this->model_products>get_product($store,$category,$product_slug);     $data['title'] = $data['products'][0]->product_name; } 

my question is, there way load stuff in sort of wrapper class avoid polluting each of classes methods (and calls these methods within other methods above) needed wrapper view.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -