• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best practice for including headers and footers

In my application's views folder, I created a CakePHP-esque layouts folder. With the layouts folder I put "front", "admin" and "minimal" folders. Within each of these, I put a header.php file and a footer.php file.

Right now, I am putting this code into my controller to include headers and footers:
class Items extends Controller {

   function view($id) {

      // Get item
      // ...

      // Render
      $this->load->view("layouts/front/header", array('page_title' => $data['item']['title']));
      $this->load->view("items/view", $data);

What I'm asking is, is there a better way to go about applying layouts than this?

I put something similar into a library and autoloaded it. Mine does a bit more (loads CSS and JS files as well), but all in one line of code instead of many.



[quote author="EEssam" date="1214195442"]http://ellislab.com/forums/viewthread/81780/

Thanks for that.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.