Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
front controller best practice
  • Hello,

    I am having a little problem (I might have overseen something):
    So I want to have a controller or something, which defines the template.
    Then I want another controller, like a front controller, which assings modules to the partials of the template also kinda based on the URL Request.
    I see there one problem: The URL request normally is calls on controller, how do i assign all partials based on one call?
    I was thinking about a database driven controller, which is called (everything is routed to this controller, ok maybe something like admin/x, is routed towards an backend controller) and processes the called method. In this method the controller makes some database queries to get informations about the different module assigned to the partials.

    Is that the right way or am I completely wrong about this?
    Any help is appreciated.

    Greetings,

    accname
  • HarroHarro
    Accepted Answer
    There are several ways to go about this.

    Most people create a base controller, which will define the template and the fixed sections of the page, and have controllers that extend this base controller, and which fills in the body section of the template.

    If you have configuration (database or otherwise) driving your pages, you can create a route that will route everything to a front controller. That can do a lookup of whatever you need to display on the page (which should be a list of controller methods to call). Then call these methods using secondary requests (HMVC calls), and have those methods return View objects that the front controller can assign to the template.

    You can use the Theme class for extra flexibility, as it provides partial and chrome support out of the box.

Howdy, Stranger!

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

In this Discussion