Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Best way to avoid code duplication with templates
  • Hi guys, I'm creating a website, and is going to be a module for each section. I have a base template wrapper that is going to to be used. This template is going to have several sections - header/menu, content, sidebar, footer. These sections are all obviously dynamic. My controllers are extending \Controller_Template. What's the best way to avoid having to use a before() and after() in every one of my controllers to generate the above sections? Am I going to have to create my own \Controller_Template class to replace the default one (by copying and pasting the existing one into app/classes and modify the before()/after() there), or is there another way to do this that's already built-in?
  • Check Extending Core classes on how to extend a Core class like Controller_Template without overwriting it. Just be sure to call parent::before() and parent::after() when you overwrite those methods or the Controller_Template won't function the same anymore.
  • Okay, thought so. Works perfect. Thanks for the wonderful framework (seriously!). I always wanted to get into Kohana - but the docs weren't good enough when I was looking. I used CI for a long time, but I found it was too much 'convention' over 'configuration' and that there were limits to the things I could do with it. So far, it seems like Fuel is just the right balance. I love that it's PHP 5.3, and as a result it's super easy to overload anything - yet still have access to the original if ever needed. Thanks again!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion