![]() |
Architecture Header - Body - Footer - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Architecture Header - Body - Footer (/showthread.php?tid=18181) |
Architecture Header - Body - Footer - El Forum - 04-28-2009 [eluser]DCZ[/eluser] Hey everybody ! I want to bounce an idea to see what other people think and if they have better solutions. Since my header and footer are the same on every page I would like to add them as simple as possible to every page. I used to have code like this : --> load_header(); --> load_body (arg[]); --> load_footer(); --> print_to_screen(); And the load_body would call a differnt page depending on the url parameters. So I would only have to load my header and footer only once. Now I would like to start using CI. So in order to have the same result I've created a MY_Controller that extends the controller class. Inside I have 2 functions "load_header" and "load_footer". Every new page extends MY_Controller, but I still have to call on every page "load_header", "load_footer" in order to print my header and footer. So now I was wondering if there wasn't a better way ? Greetz Architecture Header - Body - Footer - El Forum - 04-28-2009 [eluser]Dam1an[/eluser] The way I do it, is to have a render function in MY_Controller This loads the default header and footer and specified body view You then just have to call render at the end of your functions (I've got around this using a post controller hook, but don't want to complicate things for you just yet) Architecture Header - Body - Footer - El Forum - 04-28-2009 [eluser]xwero[/eluser] The simplest solution is to use a post_controller hook where you load the base template. Code: // hook function (basic) |