"Main view" |
[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!
[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>
[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?
[eluser]donald.tbd[/eluser]
Thanks, was reading up on my_controller and found this in the wiki: http://codeigniter.com/wiki/Header_and_F...ge_-_jedd/ |
Welcome Guest, Not a member yet? Register Sign In |