![]() |
passing variables to views - 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 variables to views (/showthread.php?tid=35978) |
passing variables to views - El Forum - 11-17-2010 [eluser]mironcaius[/eluser] Hello, I have just started working with CI but I am having problems with views. I want to be able to pass variables and objects to a main view, that will include different files. Something like: Code: $this->load->view('page', 'page1'); Code: <html> The idea behind this to pass variables and control what blocks or php pages to include. Also is their a method to pass variables to the view without loading a php page? Please help because I am thinking to drop CI because of this lack. passing variables to views - El Forum - 11-17-2010 [eluser]Dennis Rasmussen[/eluser] [quote author="mironcaius" date="1290002738"]Please help because I am thinking to drop CI because of this lack.[/quote] Did you even read the documentation? http://ellislab.com/codeigniter/user-guide/general/views.html Yes I'm being harsh on you, because you didn't RTFM and then blame CI. passing variables to views - El Forum - 11-17-2010 [eluser]mironcaius[/eluser] Yes, of course i have read the manual. I have read everything searching for an example. also reviewed some template system. Anyhow: Code: $data['page_title'] = 'Your title'; is their a method to do just that ? Don't get me wrong, I reaaaallly want to use CI, this is why i am asking for help. Sorry if i said something wrong. passing variables to views - El Forum - 11-17-2010 [eluser]Dennis Rasmussen[/eluser] You can send any kind of data to your view. If you need some data for all of your views and subviews (you can use $this->load->view('') within another view), you can use $this->load->vars($data) and $data will be available in your entire application (both controllers and views). You can also access CI from your view with $this->library_name, $this->model etc. passing variables to views - El Forum - 11-17-2010 [eluser]mironcaius[/eluser] Exactly what i was looking for, thanks. Quote:You can also access CI from your view with $this->library_name, $this->model etc.This is very nice feature. I created a model. Code: <?php Code: <?php From here i simply need to see how to organize the includes or views to display the entire html. Probably i will research and if i cannot find a valid solution i will open a new post, thanks. passing variables to views - El Forum - 11-17-2010 [eluser]Dennis Rasmussen[/eluser] You're welcome ![]() |