Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Default _root_ route design question
  • I would like to load the default route in home from a setup in fuel,

    is it a good design from app/routes.php ?

    https://bin.fuelphp.com/snippet/view/OC

    Here I don't know how test the class before send $default_home_route to _root_
    else not I send to a default static page.

    thanks
  • HarroHarro
    Accepted Answer
    I assume your question is how to test if the request is routable? That is not so easy, and not doable at that point in the framwork flow, as the routes aren't loaded yet.

    Instead, I would leave the routes.php with the default route:

        '_root_'  =>  'media/frontend/homepage/index',

    And then in your app bootstrap, at the bottom (so after loading the config):

    // create the site root uri
    \Config::load('app-setup', 'application');
    $uri = 'media/frontend/index/'.\Config::get('application.setup.site.default');

    // if it exists, set it as the default homepage
    if (\Router::process(\Request::forge($uri)))
    {
         \Router::add(array('_root_' => $uri));
    }

    NB: disclaimer, this is from the top of my head. ;-)

Howdy, Stranger!

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

In this Discussion