passing variables to views |
[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.
[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-gui...views.html Yes I'm being harsh on you, because you didn't RTFM and then blame CI.
[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.
[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.
[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.
|
Welcome Guest, Not a member yet? Register Sign In |