phpfuelphpfuelphp-routing

Fuelphp - pass default parameter to a controller in a rewrote route


I want to do something I thought was pretty basic using fuelphp Basically I need to use multiple urls with only one controller, and assign each different route a default parameter (a cat id for that matter)

For instance in my Listing controller I want to use 2 different routes :

/bags
/accessories

to each of which would be assigned it's cat id

Can't seem to find any easy way to do it in fuelphp...


Solution

  • You can specify a route like 'path/here/(:segment) => 'controller/cat/$1 which will then pass the segment captured in the route as the first parameter to a method called action_cat in the controller class.

    This behaviour is pretty well outlined in the documentation http://fuelphp.com/docs/general/routing.html