![]() |
"Main view" - 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: "Main view" (/showthread.php?tid=41398) |
"Main view" - El Forum - 05-06-2011 [eluser]donald.tbd[/eluser] Hello, Ive been working with php for some time now but i am new to CI and wanted to ask a little bit of guidance. Before CI i used my own framework and i like CI because it reminds me a little bit of my own. In my own framework i had a static frame, that i called "main view". It looked a bit like this: <html> <head> ... </head> <body> <div class="header">...</div> <div class="menu">...</div> <div class="menu"><?=$content?></div> <div class="footer">...</div> <body> </html> Now everything in this view is pretty much static except the $content part. $content was the dynamic part and it was basicly another "subview" passed down to this "main view". "Subview" could just be a table of dynamic content witohut anything else" The point of this "main view" was ofcorse not to write every static part again and again. It could be used like this: <?php $data = *selection from db or something like this* $subview = $this->loadView('subview', $data); $mainview = $this->loadView('mainview', $subview); print $mainview; ?> Now ive been looking around but cant seem to find how can i accomplish something similar in CI. I would be thankful for any advice! ![]() "Main view" - El Forum - 05-06-2011 [eluser]cideveloper[/eluser] This will work. Check Returning views as data at the bottom. controller Code: $db_results = "selection from db or something like this"; view Code: <html> "Main view" - El Forum - 05-07-2011 [eluser]donald.tbd[/eluser] Thank you ![]() "Main view" - El Forum - 05-14-2011 [eluser]donald.tbd[/eluser] Just out of interest, is there a better way of keeping views seperate from everything static? How do you guys keep from typing the static stuff over and over again? "Main view" - El Forum - 05-14-2011 [eluser]InsiteFX[/eluser] MY_Controller InsiteFX "Main view" - El Forum - 05-15-2011 [eluser]donald.tbd[/eluser] Thanks, was reading up on my_controller and found this in the wiki: http://codeigniter.com/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/ |