Welcome Guest, Not a member yet? Register   Sign In
Send the same data to multiples views
#1

[eluser]Unknown[/eluser]
i was working with multiples views...i was read it before in other post and it works well...but, imagine that you have this
Code:
$data_principal['base']=$this->config->item('base_url');  //just some paths in my config
...more variables...

$data_principal['base']=$this->config->item('base_url')   // the same paths
...more variables...

$data_principal['content']=$this->load->view('content',$data_paths,TRUE);   //here
$this->load->view('index',$data_principal);

how i can send the content of $data_principal to 'content' view and 'index' view at the same time with a single array??

thanks a lot
#2

[eluser]zagrad[/eluser]
Well, first of all: In the above code sample you are putting the same URL (base_url) in the same array (data_principal). I'm assuming that the following is what you meant to do:

Code:
$data_principal['base']=$this->config->item('base_url');  //just some paths in my config
...more variables...

$data_principal['content'] = $this->load->view('content',$data_principal,TRUE);
$this->load->view('index',$data_principal);

Gr,
Paul
#3

[eluser]zagrad[/eluser]
Oh and if you want to have the view 'content' to have some more variables (now contained in $data_paths), but you don't want the 'index' view to have those variables, you can ofcourse do something like this:

Code:
$data_principal['base']=$this->config->item('base_url');  //just some paths in my config
...more variables...

$content_data['some_other_var']='something';
...more variables...
$content_data = array_merge($content_data,$data_principal);

$data_principal['content'] = $this->load->view('content',$content_data,TRUE);
$this->load->view('index',$data_principal);




Theme © iAndrew 2016 - Forum software by © MyBB