Welcome Guest, Not a member yet? Register   Sign In
Best practice for including headers and footers
#1

[eluser]mattalexx[/eluser]
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:
Code:
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);
      $this->load->view("layouts/front/footer");
   }

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

[eluser]Raiko[/eluser]
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.
#3

[eluser]EEssam[/eluser]
http://ellislab.com/forums/viewthread/81780/

Smile
#4

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

Smile[/quote]
Thanks for that.




Theme © iAndrew 2016 - Forum software by © MyBB