Welcome Guest, Not a member yet? Register   Sign In
Loading multiple views concurrently - $data array can't be used unless it's loaded in the first!
#5

[eluser]stormbytes[/eluser]
Excellent suggestion - Thanks! Smile

The manual says...
Quote:$this->load->vars($array)

This function takes an associative array as input and generates variables using the PHP extract function. This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might want to use this function independently is if you would like to set some global variables in the constructor of your controller and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached and merged into one array for conversion to variables.

So here's my follow up question -

I'm a bit fuzzy when it comes to variable scope & encapsulation, especially with CI. The manual says that I can place this call in the Constructor to make it available to all the functions (methods) of that class. So then, I can put this call in my Constructor and pretty much forget about it, knowing that all my $data values will be available to any view in a SuperGlobal.

That about right?


Messages In This Thread
Loading multiple views concurrently - $data array can't be used unless it's loaded in the first! - by El Forum - 10-04-2010, 06:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB