![]() |
multiple views - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: multiple views (/showthread.php?tid=11505) |
multiple views - El Forum - 09-10-2008 [eluser]home158[/eluser] Hi everyone, When I load multiple views,like this. Code: $this->load->view('head'); Do I forgot somethings? How could use multiple views in my system? Thanks. multiple views - El Forum - 09-10-2008 [eluser]Michael Wales[/eluser] I assume you are placing that code within your controller. Load a single view from your controller and then load your others views from that main view. I usually do something like this: controller Code: function index() { views/layout.php Code: $this->layout->view('header'); multiple views - El Forum - 09-11-2008 [eluser]mglinski[/eluser] Multiple views inside controllers works just fine. Make sure there are no php errors in footer view, as if there are errors in any view only the view with errors will be shown. Check the source output for any hidden errors. -Matt multiple views - El Forum - 10-15-2008 [eluser]Jesse Schutt[/eluser] Michael, Are you saying that it is ok to load additional views from within a view? I'm just trying to get my head around "embedding" (Can you hear the EE-speak?) things like my footer, header, and nav views so one change will ripple through the site... Thanks! Jesse multiple views - El Forum - 10-15-2008 [eluser]John_Betong[/eluser] I prefer to use the Loader Class in the Controllers. The CodeIgniter Help file has details. controller/home.php Code: ... view/home.php Code: <?= $doctype ?> This technique maybe long winded but I find it easy to go read the code, debug and to modify the view files to ensure they have no Html validation errors. multiple views - El Forum - 10-16-2008 [eluser]Jesse Schutt[/eluser] Hey! Thanks for writing this out. This makes a lot of sense! I probably should know this, but why do you have some of the comments wrapped in php tags? Is it so they don't render to the browser? Again, thanks for helping with this! Jesse multiple views - El Forum - 10-16-2008 [eluser]John_Betong[/eluser] I am pleased that the code was useful and easy to understand. Yes the comments wrapped in the PHP tags can only be seen in development. Just a little less code to be displayed in the browser to help bandwidth. |