Header/Footer layout best practice? - 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: Header/Footer layout best practice? (/showthread.php?tid=15222) |
Header/Footer layout best practice? - El Forum - 01-29-2009 [eluser]spyro[/eluser] When I started building my CI application I extended the Controller with MainPage.php so that every time I extended MainPage with a new controller I could automatically get the header and footer in the page without having to call the header/footer each time. MainPage looks as follows. Code: class MainPage extends Controller { The problem that I have now is that I have no way to set the title or metadata in the header view because it is being extended. Is there a way to correct this with my current layout? If not, what is the best approach for headers/footers that also minimizes code? Header/Footer layout best practice? - El Forum - 01-29-2009 [eluser]Jelmer[/eluser] I do it through a wrapper view, a lot easier and works like a charm. You call the view like this: Code: $data['view'] = 'example'; // the name of the view you want to load And then your wrapper.php view looks like this: Code: <html> with the example.php view: Code: <p><?php echo $example; ?></p> Which gives as output: Code: <html> You could also use the forum's search function as this question has been asked countless times before, and there are other good solutions... Header/Footer layout best practice? - El Forum - 01-29-2009 [eluser]The Wizard[/eluser] i do it with a custom system ive developed for it, i store the files in views\themes\default -----------------------header -----------------------footer -----------------------pages -----------------------------foldername1 -----------------------------foldername2 -----------------------------master-file_name.php i setup the themeing system from within the controller, load the them_folder_variable + master-file_name which will look in the themes\ folder with the actual selected theme (which in our, example is default). IF the master file loaded, will need another file releated to that function, it looks into its own DIRECTORY in this example "foldername1". the code looks like: model_theme Code: <?php example controller load code Code: /* Theme System with Reference Variable. */ example master file: Code: <? $this->load->view( $theme_folder . 'header/normal/header.php'); pretty self explaining ?> |