CodeIgniter Forums
determine all variables passed into 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: determine all variables passed into view (/showthread.php?tid=8737)



determine all variables passed into view - El Forum - 05-29-2008

[eluser]louis w[/eluser]
when inside of a view is there a way to access the array of variables which was passed in as a whole? i need to call a sub-view and want to pass everything into the next view but don't know all the the variable names (they will change) which were in the array.


determine all variables passed into view - El Forum - 05-29-2008

[eluser]gtech[/eluser]
you don't need to pass them on to a sub view..

what happens is when you pass a data array to a view, all other views in the same request will have those variables available. I believe this is because the loader class stores the view variables and does not unset them everytime you load a view.


determine all variables passed into view - El Forum - 05-29-2008

[eluser]louis w[/eluser]
Oooooh. They are one step ahead of me.

Thanks for making me aware of this.


determine all variables passed into view - El Forum - 05-29-2008

[eluser]gtech[/eluser]
The load class has "_ci_cached_vars" array available in the controller or view, and gets built up everytime you load a view and pass in a data array.
Code:
print_r($this->load->_ci_cached_vars);



determine all variables passed into view - El Forum - 05-29-2008

[eluser]gtech[/eluser]
No probs I only recently found this out myself.


determine all variables passed into view - El Forum - 05-29-2008

[eluser]gtech[/eluser]
sorry got to send another message as my total post count was the same as the devil.


determine all variables passed into view - El Forum - 05-29-2008

[eluser]Chris Newton[/eluser]
The devil posts here? Wink


determine all variables passed into view - El Forum - 05-29-2008

[eluser]gtech[/eluser]
yep and also shops at Tesco's.