parameter passing

Associate
Joined
19 Jul 2006
Posts
1,847
I have this code
Code:
$this->load->view('editclient_view', $data);
			//$view['main_content'] = 'editclient_view';
			//$this->load->view('includes/template', $view, $data);

Basically what I normally do is set a $view then pass it to the load view which puts it in the main area of the template. So usually its
PHP:
//$view['main_content'] = 'editclient_view';
			//$this->load->view('includes/template', $view);

However this time I need to pass $data to the view to so
PHP:
$this->load->view('editclient_view', $data);
works but doesnt load the proper templates.
Any ideas?
 
Associate
Joined
11 Mar 2007
Posts
1,741
I'm guessing your view loader is setup to look for a main_content variable so it knows what view to load. Try setting it and then just add your other parms to the array.


$data['main_content'] = 'editclient_view';
$data['my_data_one'] = 'blah';
$data['my_data_two'] = 'blah2';

$this->load->view( 'includes/template', $data );
 
Associate
Joined
16 Mar 2009
Posts
427
Location
London
$view['main_content'] = 'editclient_view';
$view['data'] = $data;

That is what will make $data available in the view (as $data). Although I'd rename $view to something else (what post above has done).

Depending on what $data is that your passing, you may want to structure that part of the array slightly differently to make it easier to extract on the other end.

+1 to renaming $view.
 
Back
Top Bottom