I am looking for the best way to process my template. Right now, my template looks something like this:
View / template.php
$this->load->view('includes/menu', $menu); $this->load->view('includes/content', $main_content);
The menu in my template uses several variables from the database.
My controller looks something like this:
function show_pageA() { $data['menu'] = array of variables pulled from previous line $data['main_content'] = 'pageA'; $this->load->view('template',$data); } function show_pageB() { $data['menu'] = array of variables pulled from previous line $data['main_content'] = 'pageB'; $this->load->view('template',$data); }
As you can see, each page function has 10 lines of code related to the menu, and this seems superfluous to me.
Can someone suggest me a better way to do this while practicing MVC?
Thanks,
source share