How do I reference variables from the controller into a 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: How do I reference variables from the controller into a view? (/showthread.php?tid=50034) |
How do I reference variables from the controller into a view? - El Forum - 03-11-2012 [eluser]Unknown[/eluser] Needing a little assistance with setting up multiple view references from within on controller function. Maybe I am setting this up wrong and if so please let me know. Question is how do I carry stored variable data like the $seo array listed below from the controller into the view if the view is loaded from the controller. Views: View1: header Code: <!DOCTYPE html> View2: navi Code: <div id="menu"> View3: footer Code: <div id="footer"> Controller: Code: class User extends CI_Controller { How do I reference variables from the controller into a view? - El Forum - 03-11-2012 [eluser]Aken[/eluser] http://ellislab.com/codeigniter/user-guide/general/views.html How do I reference variables from the controller into a view? - El Forum - 03-11-2012 [eluser]Unknown[/eluser] Thank you. Had looked at that document but was having problems understanding it. Looked it over again now knowing it does contain what I wanted and ran tests until I successfully got this to work. How do I reference variables from the controller into a view? - El Forum - 03-11-2012 [eluser]Aken[/eluser] Passing dynamic data to views is an incredibly important and common feature with CI apps. Definitely learn how to do it properly. How do I reference variables from the controller into a view? - El Forum - 03-12-2012 [eluser]rulin[/eluser] Hi Creator In your controller you create an array of values and pass it to the view as the 2nd parameter Code: $data = array(); then in you view you reference the array element as a variable Code: <meta name="keywords" content="<?PHP echo $seo_keywords ?>" /> Code: <?PHP echo $menu ?> |