Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuelphp templating
  • I'm trying to develop a small application in FuelPhp and i need some advices.



    I have a classic template with a main column and a sidebar.

    In the sidebar i have to render several blocks with static and dynamic content depending on what page i'm displaying.



    I.e. if i visit the URL:



    controllerA/some_action:

    in the sidebar i want to display the following blocks:

    - latest article (dynamic content)

    - latest users (dynamic content)

    - login form (static content)



    controllerB/some_action:

    in the sidebar i want to display the following blocks:

    - login form (static content)

    - most visited articles (dinamici content)



    What kind of approch would you use?

    1) Extending the template controller and using an array of blocks to render?

    2) Using one or more presenter?

    3) Other?



    Thanks in advance for any suggestion.
  • If your application is small, I would use a base controller that extends the template controller.

    In the before method of this controller, I would define the page template, and all static sections of the template. Have your application controller extend this base controller. In its before method, call the parent, and then have it set all sections that are the same for all methods in that controller. And set the remaining sections, the dynamic ones, in the controller methods.

    If your application is a bit bigger, you might want to look at the Theme class, which gives you more functionality when it comes to page templates. It is loosely modelled on Joomla's theme layout, and supports multiple views per section, section chrome (for example borders around your entire sidebar), themes with fallback, etc.

    Same if you need more flexibility, for example if you have multiple page templates, a front-end with a different layout from your admin section, etc.
  • Thanks for reply, i'm using the theme feature
  • Ok, then the same method applies, but the base controller should extend the normal controller, not the template controller, and it it's after method, return a response with the theme object in it.

Howdy, Stranger!

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

In this Discussion