I'm looking for example of how to use constructor loaded controller data in my view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: I'm looking for example of how to use constructor loaded controller data in my view (/showthread.php?tid=51460) |
I'm looking for example of how to use constructor loaded controller data in my view - El Forum - 05-04-2012 [eluser]bill19[/eluser] Hi, Hi I've been reading in http://ellislab.com/codeigniter/user-guide/libraries/loader.html on how to use $this->load->vars($array) to make array elements available in views, but I can't get this working. Here is my controller: Code: class Home extends Admin_Controller { which extends controller: Code: class Admin_Controller extends MY_Controller { my view (user_view) is: Code: h1>Protected View!!</h1> What do I have to do to print out the value of element 'id' of the $data array? Thanks in advance for your help, Bill I'm looking for example of how to use constructor loaded controller data in my view - El Forum - 05-04-2012 [eluser]ojcarga[/eluser] I'm not really sure what you are doing extending those clases... but, Are you sure the $data variable is really an <b>associative</b> array?? "This function takes an associative array as input and generates variables using the PHP extract function. " Did you try using Code: $this->load->view('user_view', $data); Code: $this->load->vars($data); I'm looking for example of how to use constructor loaded controller data in my view - El Forum - 05-04-2012 [eluser]CroNiX[/eluser] $data needs to be an associative array, you created an object. What you're doing with load::vars() should be fine once you pass it the data in the correct format. I'm looking for example of how to use constructor loaded controller data in my view - El Forum - 05-04-2012 [eluser]bill19[/eluser] Thanks for the explanation Cronix. Ojcarga, I'm trying to follow http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY Cheers, Bill |