CodeIgniter Forums
From within a view, how to see all variables passed into it from controller? - 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: From within a view, how to see all variables passed into it from controller? (/showthread.php?tid=11731)



From within a view, how to see all variables passed into it from controller? - El Forum - 09-21-2008

[eluser]inktri[/eluser]
Quote:
Code:
<?php
//master view - index.php
$this->load->view('header');
$this->load->view($page);
$this->load->view('footer');
?>
And then from my controller

Code:
$this->data['page'] = 'somepage';
$this->load->view('index', $this->data);
[/code]

I'm using the method above to handle headers and footers; however I can't think of a clean way to handle passing data into the 'somepage' view. From within the 'master view', what's the array that holds all data that's passed into it?

For example if I were to do:
Quote:
Code:
<?php
//master view - index.php
$this->load->view('header');
$this->load->view($page, $xxxxxxxxx);
$this->load->view('footer');
?>
And then from my controller

Code:
$this->data['page'] = 'somepage';
$this->data['data1'] = 'bob';
$this->load->view('index', $this->data);
[/code]

How would I pass the data1 piece of data to the 'page' view (through the 'master view')? I need to handle the general case... so from the point of view of the 'master view' I don't know how many or what variables will be passed in to me

Thanks for the help


From within a view, how to see all variables passed into it from controller? - El Forum - 09-21-2008

[eluser]sophistry[/eluser]
i think you are looking for $this->load->vars() . see the user guide for details. basically, it loads variables into a kind of "global" scope for all views.