Advice regarding best practices with Codeigniter - 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: Advice regarding best practices with Codeigniter (/showthread.php?tid=58434) |
Advice regarding best practices with Codeigniter - El Forum - 06-12-2013 [eluser]epseix[/eluser] Guys, I am looking for a bit of advice regarding structure and/or best practice for page content through Codeigniter MVC. My website template takes the standard structure of having a main content section on every page (populated by MySQL), with a static header, footer and sidebar of common links, features etc. I've learned how to work with the database and Codeigniter MVC and as far as my main content goes. However... I now need to begin to populate the data for my sidebar and header/footer etc. - and I'm unsure about the best way to instigate other MySQL queries around the main query to do this. Is auto-loading the most readily-used solution? Would I create these queries in a helper, or would I have to load with every controller? I suppose my real question is - what does everybody else do? Advice regarding best practices with Codeigniter - El Forum - 06-12-2013 [eluser]satie[/eluser] Too many questions. Post an example. Advice regarding best practices with Codeigniter - El Forum - 06-13-2013 [eluser]epseix[/eluser] [quote author="satie" date="1371073149"]Too many questions. Post an example.[/quote] Sure. Question 1:- My view file requires output from 2 separate mySQL queries - how do I implement a second mySQL query into the MVC framework of Codeigniter? (Although I think this should probably be in the Coding forum) Question 2:- Is this (ie. a second or third mySQL query) the best method for generating data for the likes of a header, footer, sidebar etc. eg. my sidebar contains a list of links for last 5 blog entries which are stored in the database. Regards, Advice regarding best practices with Codeigniter - El Forum - 06-13-2013 [eluser]satie[/eluser] Ok: Controller: Code: public function riepilogo() In templates/main: Code: if (isset($main_content)) { |