![]() |
codeigniter passing data to inner include php - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: codeigniter passing data to inner include php (/showthread.php?tid=62153) |
codeigniter passing data to inner include php - rchiu5hk - 06-14-2015 Dear all, I am using codeigniter to develop php web site. Now I have the question. In controller, $this->load->view('index', $data); I want $data can also share in header.php and footer.php that included in index.php. It seems they cannot share and show undefined variables in header.php and footer.php. How to do??? RE: codeigniter passing data to inner include php - solidcodes - 06-14-2015 In your controller you need to include the $data. Use array $data and include it into your header and footer. $data = array(); $this->load->view('header', $data); $this->load->view('footer', $data); RE: codeigniter passing data to inner include php - InsiteFX - 06-15-2015 Or do it this way, make $data global to all views. PHP Code: $data = array(); RE: codeigniter passing data to inner include php - iamthestreets - 06-24-2015 Where would i add this code? I don't want to have to repeat all the data in every controller functions. RE: codeigniter passing data to inner include php - John_Betong - 06-24-2015 Where and how do you load footer.ohp and header.php? RE: codeigniter passing data to inner include php - InsiteFX - 06-24-2015 (06-24-2015, 01:03 PM)iamthestreets Wrote: Where would i add this code? I don't want to have to repeat all the data in every controller functions. Then create a MY_Controller RE: codeigniter passing data to inner include php - solidcodes - 06-25-2015 @InsiteFX How do you make the variable GLOBAL in the MY_Controller. Can you show us the complete codes. sorry a little rusty here since I've been to Laravel. Thanks in advance. RE: codeigniter passing data to inner include php - frocco - 06-25-2015 Code: class MY_Controller extends CI_Controller |