Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing to a pages module without loosing normal routing
  • I have my routes.php file set to route anything (:any) to a pages module, so things like index.php/welcome or index.php/contact would be handled by modules/pages/

    I would then route my other normal modules using module(/:any) so that a url like
    module/users/profile would work with "module" prefixed.

    I need to get away from that "module" part so that modules can also be called by the first segment in the url.

    If a page and module have have the name, segment[0] one would overwrite the other and thats ok.

    Any idea on how to setup routes for something like this? Current routes.php file is here: http://bin.fuelphp.com/snippet/view/ks


  • You can't. "module" is what uniquely idenfies the module (and therefore the location of it's classes folder), and the module namespace.

    If you get a request for say "/something/", how would that map to a controller called \Module6\Controller_Something ?

    This will be fixed in v2, where URI prefix and namespace will be decoupled, so you can have multiple locations that all define the same URI prefix, and even have the same namespace.
  • HarroHarro
    Accepted Answer
    Maybe as a workaround, you could have your (:any) route point to a front controller.

    It can pick up the URI, check if it maps to something in a module somewhere. If so, fire an HMVC request for the URI, prefixed with the correct module name. If no match is found, do HMVC call to your pages controller?

Howdy, Stranger!

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

In this Discussion