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!
#1

[eluser]stormbytes[/eluser]
So, referencing the UG - http://ellislab.com/codeigniter/user-gui...views.html

When loading multiple views.. Eg.:
Code:
$this->load->view( 'header' );
$this->load->view( 'hello', $data );
$this->load->view( 'sidebar' );
$this->load->view( 'footer' );

The $data array (variables) are only accessible *after* the load statement which included $data has been 'processed'. Meaning, if you have header elements that depend on $data-variables, you'll get an error. The way I've remedied this is by loading $data into the very first load statement (eg - $this->load->view('header', $data).

I'm wondering if this is something the dev team will want to change in the upcoming release of v.2. or if I'm overlooking something?

My understanding was that everything is pre-buffered, in which case it shouldn't make any difference what order the Load-statement containing the $data array appears in.

Curious to hear thoughts...


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-03-2010, 08:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB