CodeIgniter Forums
the array from the controller into the view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: the array from the controller into the view (/showthread.php?tid=40689)



the array from the controller into the view - El Forum - 04-15-2011

[eluser]rvent[/eluser]
Hello,

I am loading different views:

Code:
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');

Now i am know can do: $this->load->view('header', $data); and be able to use the data passed in my view, but do i have to do it on each view, or will the data be available to all view if i just do:

Code:
$this->load->view('header', $data);
$this->load->view('content', $data);
$this->load->view('footer', $data);

I would think you could just do:
Code:
$this->load->view('header', $data);
$this->load->view('content');
$this->load->view('footer');

And be ok using data in the other views..

Any ideas..?

Thanks


the array from the controller into the view - El Forum - 04-15-2011

[eluser]InsiteFX[/eluser]
Code:
// make data for all views!
$this->load->vars($data);

this->load->view('header');
$this->load->view('content');
$this->load->view('footer');

InsiteFX


the array from the controller into the view - El Forum - 04-15-2011

[eluser]rvent[/eluser]
oh snap, i forgot about vars...

Thanks!