What's the practical way to load header and 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: What's the practical way to load header and footer (/showthread.php?tid=9007) Pages:
1
2
|
What's the practical way to load header and footer - El Forum - 06-08-2008 [eluser]EEssam[/eluser] Hello, I'm wondering what is the most practical way to load a header and a footer. I know I can do: $this->load->view('header'); $this->load->view('myview'); $this->load->view('footer'); But I just don't see how I should call this in almost each function in my controller classes. Please advise. What's the practical way to load header and footer - El Forum - 06-08-2008 [eluser]Gavin Blair[/eluser] I start every view with <?php include 'header.php'; ?> and end each view with <?php include 'footer.php; ?> and everything else goes in between. What's the practical way to load header and footer - El Forum - 06-08-2008 [eluser]EEssam[/eluser] I found this method used by scaffolding: <? $this->load->view('header') ?> Not sure if it's the best. What's the practical way to load header and footer - El Forum - 06-08-2008 [eluser]Armchair Samurai[/eluser] The basic one I use for simple sites is to have a template view file which is set up something like this: Code: <?php Code: /* In your a controller function */ What's the practical way to load header and footer - El Forum - 06-08-2008 [eluser]stuffradio[/eluser] I always do: Code: <?php What's the practical way to load header and footer - El Forum - 06-09-2008 [eluser]Bramme[/eluser] Same as armchair samurai... I create a masterviewfile like this Code: <?php Code: $this->data['page'] = 'somepage'; Seeing as your data gets transferred to your 'subviews' automatically, it works as a charm! [/code] What's the practical way to load header and footer - El Forum - 06-09-2008 [eluser]xwero[/eluser] I tend to use the template inheritance helper. It make the load->view more meaningful and other people can trace master pages by only looking at view files. What's the practical way to load header and footer - El Forum - 06-09-2008 [eluser]tjmthome[/eluser] yes, I agree with Bramme, i found the easyest way is a 'masterview' page (yes i know this maybe breaks a little MVC) but is practical What's the practical way to load header and footer - El Forum - 06-09-2008 [eluser]JoostV[/eluser] I use one master template from which I include header, footer, navbar, and so on. I always seem to have one content template that has to be loaded dynamically. I set this in the controller, before I load the main template, like so: Code: $this->data['pagvars']['contentview'] = 'name_of_template'; Now, in the template I load this specified template, if it exists: Code: if (isset($pagvars['contentview']) && file_exists($pagvars['contentview'] . '.php')) { What's the practical way to load header and footer - El Forum - 06-22-2008 [eluser]mattalexx[/eluser] [quote author="tjmthome" date="1213046956"]yes, I agree with Bramme, i found the easyest way is a 'masterview' page (yes i know this maybe breaks a little MVC) but is practical[/quote] How does that break MVC? |