![]() |
Passing Data to 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: Passing Data to View (/showthread.php?tid=54199) |
Passing Data to View - El Forum - 08-28-2012 [eluser]Unknown[/eluser] I have a controller that sends an email, then loads a view: $data['title'] = 'Contact Us'; Code: $email_data = array('message' => 'This is the message'; And in my view (contact.php): Code: <?php if(!empty($message)) : ?> Even if there's no problem sending the email, the Code: $message So, even though the Code: $data Code: 'message' I realize that a really simple work around is to initialize any indexes of our "final" $data array that may possibly exist in any other $not_data arrays passed to views that may be loaded before loading our "final" view. But should I have to do this? Is this the intended behavior? Thanks! Passing Data to View - El Forum - 08-28-2012 [eluser]Aken[/eluser] CI "caches" view variables in order to make variables available to views embedded inside views. So it's normal for that to happen, but I can see how it may not be what you expect. You should create an issue, or even a pull request if you have a suggested solution, on Github. See if others have this problem or empathize enough to create a solution if you haven't suggested one. Passing Data to View - El Forum - 08-30-2012 [eluser]Unknown[/eluser] Sounds good. Thanks for the reply! |