Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
FuelPHP - Building a page in blocks
  • What is the best way to build a page in FuelPHP so that each of the blocks of the page are built on their own as modules and then the output HTML is put together in a layout.

    The best i have found thus far is the HMVC with something like the below.


    $block1= Request::forge('mycontroller/block1')->execute();

    $block2= Request::forge('mycontroller/block2')->execute();

    $data['block1'] =$block1;

    $data['block2'] = $block2;

    //assign the view to browser output

    return View::forge('home/index', $data);

    However loading up the who framework for the calls seems rather inefficient and slow. Is there a better way to do this?

  • HarroHarro
    Accepted Answer
    You're not loading the entire framework for HMVC calls, you're just creating a secondary request, the overhead of that is quite limited (compared to the framework setup).

    It is the proper way to do it, lously coupled, and if you put it in a try/catch block, it can also deal with a module not being there (by catching the 404). Also, a standard request will utilize the routing engine, so you can easily reroute requests to other modules without changing your code.

    You also need a request to properly setup and call a controller, you can't call a controller class directly.
  • Hi there!

    I wish to mention, for those who wonder about the performance penalty, on my box an hmvc call is less than 1 milisec, it's very light.

    My box is an iMac with i5 proc.
  • Thanks Harro, that was just the information I needed. Thanks also for the adviceof putting it in a try/catch block!

Howdy, Stranger!

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

In this Discussion