Advanced module routes and wildcards

edited July 2011 in Feature Requests
I can't seem to work out how to use wildcards inside an advanced module's routes config:

$route[FUEL_ROUTE.'module/model/action/:num'] = 'controller/method/$1';
gives a 404, but if i do it like this:

$route[FUEL_ROUTE.'module/model/action/1'] = 'controller/method';
Works if i go /1 in the URL bar... what's wrong?

Comments

  • edited 5:47PM
    I believe you need to wrap the :num in parenthesis:
    route[FUEL_ROUTE.'module/model/action/(:num)'] = 'controller/method/$1';
  • edited 5:47PM
    same thing...
  • edited 5:47PM
    What's real URI path and name of the module, controller and action you are wanting to map to (to better help me understand)?

    The blog uses routes similar to that but uses (.*) instead of :num (see fuel/modules/blog/config/blog_routes.php).
  • edited July 2011
    ok so,

    my advanced module is called 'akademie'. It has a number of modules. The one i'm interested in is 'akademie_links' (a simple URL -> title) thing.

    Then, my goal is to add some extra stuff, like image upload / crop a-là facebook using jcrop. Here's my strategy: leave the create/edit form as it is with the module's own form_fields, and simply add an extra action to the items listing view called 'MEDIA' (right before 'EDIT' and 'DELETE' actions on the right).

    Now when the user clicks 'MEDIA', this will send him to the 'akademie' controller's 'links_media' method. In this custom view, all the javascript goodness will take place, and stored accordingly by the same method upon POST submission. Hope it makes sense.

    This MEDIA action URL will link to

    FUEL_ROUTE/akademie/links/media/{id}
    Here's the route i'm struggling with:

    $route[FUEL_ROUTE.'akademie/links/media/(.*)'] = 'akademie/links_media/$1';
    But i get a 404 when i go to

    http://fuelcms.local:8888/index.php/fuel/akademie/links/media/2
    where 2 is obviously a akademie_links id.
  • edited 5:47PM
    Try creating a "links" controller with a media method on it instead of using the "links_media" method on your akademie controller.
  • edited 5:47PM
    Again...
    as soon as i add the wildcard (.*) or (:num) after the trailing slash of the route key, i get 404... getting crazy!!!
  • edited 5:47PM
    if only the 404 was a little more verbose...
  • edited 5:47PM
    [SOLVED] it was a matter of order. I had to put this route to the top, before the controllers array loop...
    thanks and excuse me
Sign In or Register to comment.