![]() |
passing variables from view to view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: passing variables from view to view (/showthread.php?tid=29023) |
passing variables from view to view - El Forum - 03-28-2010 [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 passing variables from view to view - El Forum - 03-28-2010 [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); passing variables from view to view - El Forum - 03-28-2010 [eluser]kmunky[/eluser] so easy ![]() ![]() passing variables from view to view - El Forum - 03-28-2010 [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. passing variables from view to view - El Forum - 03-29-2010 [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/CodeIgniter-Base-Classes-Keeping-it-DRY passing variables from view to view - El Forum - 03-29-2010 [eluser]kmunky[/eluser] thanks guys, it was a real help ![]() |