Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing _root_ for Modules
  • I have created a module namely students, I would like to get students/home/index as home page for my module homepage, for that purpose i have created routes.php in config file,

    How i do that,

    if i visit localhost/students it will render localhost/students/home/index. as in default app _root_
  • Fuel v1 doesn't support recursive routing, so you can't set a route in your app routes, and route that further in your module. Fuel v2 will support that.

    So currently the only thing you can do:

    // in your app/config/routes.php:

    return array(

        '_root_' => 'students/home/index',

    );

    Well, not entirely true, you do what you want using module routes, but it requires a redirect:

    // in your app/config/routes.php:

    return array(

        '_root_' => function() { \Response::redirect('students'); },

    );

    // in your app/modules/students/config/routes.php:

    return array(

        'students' => 'students/home/index',

    );

  • If I changed value of _root_ in app/config.i think it will change my home page. My home page ia dashbord/index I want when some one gone to module /students/ then it must execute home/index in module controller
  • HarroHarro
    Accepted Answer
    Ok, sorry, I thought that was what you asked.

    In that case only the last route will do;

        'students' => 'students/home/index',

Howdy, Stranger!

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

In this Discussion