passing variables from view to view |
[eluser]kmunky[/eluser]
considering that i have: views/page.php Code: $this->load->view("header"); controllers/show.php Code: $this->load->view("page",$data);//$data contains the main_page title and in my header view i have to pass a variable containing some categories(the site menu) to be listed. What is the correct way to accomplish this? thanks
[eluser]JoostV[/eluser]
Same as with all other views. controllers/show.php Code: $data['menu'] = array('home' => '/', 'contact', => 'contact/form'); views/hesader.php Code: echo ul($menu);
[eluser]kmunky[/eluser]
so easy ![]() ![]()
[eluser]JoostV[/eluser]
Store a base controller that you name MY_Controller in application/libraries and extend that instead of controller. Load the menu in your base controller. You will find a lot on MY_Controller on this forum.
[eluser]cahva[/eluser]
I suggest you read this great post from Phil Sturgeon on the subject of MY_Controller: http://philsturgeon.co.uk/news/2010/02/C...ing-it-DRY
[eluser]kmunky[/eluser]
thanks guys, it was a real help ![]() |
Welcome Guest, Not a member yet? Register Sign In |