loading view into another view? |
[eluser]nuttynibbles[/eluser]
hi, i would like to load view into another view file. e.g: View files: These are the 3 view files that will be called on every controller. They are the basic templates. header.php index.php footer.php index.php will look like this. So basically i include header.php and footer.php into index.php: Code: <?php this is how i will call them in the controller: $this->data['content']="hello world"; $this->load->view('index',$this->data); $this->data['content'] will contain the different forms or tables that will be displayed. Therefore, register form, login form, edit profile form and etc etc, i would like to put them into view files too. For example, the files are: register.php login.php editprofile.php so now i would like to call this reigster.php view file and put them into $this->data['content']. How can I do this? or anyone with a different idea to go about this? Thks
[eluser]Tom Glover[/eluser]
Have a look here: http://codeigniter.com/wiki/Displaying_Multiple_Views/ It shows you to ways of doing it, I prefer the second way because it means I have one template file and only my content files are reloaded constantly, this way can also be ajaxed where as way one can't.
[eluser]marcmesa[/eluser]
Displaying multiple views From the user guide: Code: <?php Also, you don't need to use include_once(). You can use $this->load->view() from your controller if you prefer.
[eluser]Michael Wales[/eluser]
I tend to do it with one master view file, then define a partial within my controller: views/view.php Code: <?php controllers/post.php Code: <?php
[eluser]Sumon[/eluser]
This one might be a good one. Code: <? $this->load->view("nanny_inc/header");?> |
Welcome Guest, Not a member yet? Register Sign In |