Hi,
I hope I’m not asking a silly question here.
I’ve got a controller and within it I have many functions, each of which have to load in the same data arrays that are used for building the navigation menu.
So for example, in my simple page function in the main.php controller you’ll see how I load in the lines 4 and 5 which are used for the menu construction:
function page() {
$this->load->helper('markdown');
// all_sections_query and page_list_query used for constructing menu
$data['all_sections_query'] = $this->Section_model->get_all_sections();
$data['page_list_query'] = $this->Page_model->get_page_list();
// load main content
$page_id = $this->uri->segment(3);
$data['page_contents_query'] = $this->Page_model->get_page_contents($page_id);
$this->load->view('main/page', $data);
}
Rather than have to instantiate them in every function, is there a way to instantiate them globally for the whole controller since they are used in every function anyway?
