Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Modules and default controllers
  • I'm having some issues with getting modules to load via their _root_ For example, let's say I have the module "testing". This module contains a routes configuration that says:
    <?php
    
    return array(
     '_root_'  => 'dashboard/index',  // The default route
     '_404_'   => 'dashboard/404',    // The main 404 route
    );
    

    When I visit mysite.com/testing/dashboard -- everything works fine. But when I visit mysite.com/testing , the default route for that module is not loaded. Am I doing something wrong here?
  • So more or less, there's no way to make "testing" run completely out of the module? The only other solutions I can think of are: - Routing it from the application
    - Creating a separate controller from within the application that redirects to testing/dashboard All of which require application modification, rather than module-only.
  • Not sure if this helps, but I've had success using the following in APPPATH/modules/testing/config/routes.php.
    <?php
    return array(
      'testing' => array('testing/dashboard/index', 'name' => 'testing'),
    );
    
  • That ALMOST works. But the problem now, is that mysite.com/testing = good
    mysite.com/testing/dashboard/index != good So I lost the other side :P
  • Afaik there is no per-module default root or 404 route supported. Those routes are global and not used as part of the routing process. _root_ is only used if there are no URI segments present (which is always the case when referring to a module. _404_ only if no route can be matched. I'm not sure if you would specify 'testing/does/not/exist', if the global or the module 404 would be used (would be interesting to document this). I think if you only specify the module name in the URI, it will look for a controller with the same name as the module. So 'testing' will become 'testing/testing/index'.
  • Basically, I'm just trying to run a sub-application that utilizes a lot of the primary application. So it would run the same way as if I had fuel installed in a /testing/ directory, and the _root_ would be pulled up as the default controller. When looking at http://fuelphp.com/docs/general/modules.html#module_routing , it says that a routes configuration can be placed in each module So when I utilize the module "testing", wouldn't site.com/testing utilize that route configuration?
  • Because the router only uses _root_ if there are no URI segments present (= when you actually do request the server root). When you request http://www.example.org/testing, you're not requesting the root, you have one URI segment, 'testing'.

Howdy, Stranger!

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

In this Discussion