How to pass all view vars (not only controller data) to another nested view |
[eluser]niverin[/eluser]
Hi, please help me with this issue! Example: main_view.php Code: $some_var = "asdlkj"; What I want is to access all parent view variables (not only controller data) in nested_view.php without manually putting them all to $data[] (don't want to change preceding code and look for all variables that are necessary to pass). So my question - is it possible to automatically create an array of all this view variables to pass it? The only method that works for me is to use include(), but you understand I would like to avoid this. Thanks for help!
[eluser]Dam1an[/eluser]
if you use Code: $this->load->vars($data);
[eluser]niverin[/eluser]
Hi Dam1an, this method returns NULL for me. Can you please describe how to use load->vars to solve my first post example? Thanks!
[eluser]Dam1an[/eluser]
You can read more about it in the user guide You call it in the controller function instead of passing $data as the second parameter to your view just before you load the views.... make sense?
[eluser]niverin[/eluser]
I am sorry but I still cannot access new variables I have defined in parent view, only have access to controller data. :-(
[eluser]niverin[/eluser]
User guide says load->vars is good for sharing variables defined in controller but this is not my case - I need to automatically pass new variables created in view to nested view - and load->vars cannot help me with it I think(or am I wrong?). Actually I have decided to give this effort up because can't spend whole day with solving this issue and have also headache from it ![]() I will process controller's data in all nested views again when need this vars (so I will create these vars again) or process them in controller and put vars to view data. Thank you again for your interest in helping me
[eluser]Dam1an[/eluser]
Why are you creating variables in the view? You should only have presentation logic in the view |
Welcome Guest, Not a member yet? Register Sign In |