CodeIgniter Forums
scope of variables not limited to one view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: scope of variables not limited to one view (/showthread.php?tid=23786)



scope of variables not limited to one view - El Forum - 10-21-2009

[eluser]tokyotech[/eluser]
Is there a way to limit the scope of variables passed into a view to only be accessible in that view? I have a header view which takes a $title variable. Then below it, i load up another popup view which should have it's own $title variable. This popup view is getting confused and reading $title from the header view.


scope of variables not limited to one view - El Forum - 10-21-2009

[eluser]imn.codeartist[/eluser]
the answer is simple "NO". Just use different variables.


scope of variables not limited to one view - El Forum - 10-21-2009

[eluser]rogierb[/eluser]
Just load your view with a different array eg:

Code:
$header['title'] = 'sample title';
$popup['title']='My very own little popup'
$this->load->view('template/header',$header);
$this->load->view('template/popup',$popup);