Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing Param return URI String
  • I am working with the Advanced Routing feature, explained here:


    I have a method named action_single which I want to direct various urls to,
    The setup is that based on the depth of the url, the more defined the result would be.

    For example, I can go to:
    /cards/1989

    and get all cards from that year
    or
    /cards/1989/baseball

    and get all cards of baseball from 1989 and so forth.

    Here are my routes:

    'cards/:year' => 'cards/single',
    'cards/:year/:manufacturer' => 'cards/single',
    'cards/:year/:manufacturer/:genre' => 'cards/single',
    'cards/:year/:manufacturer/:genre/:set' => 'cards/single',
    'cards/:year/:manufacturer/:genre/:set/:person' => 'cards/single',
    'cards/:year/:manufacturer/:genre/:set/:person/:card' => 'cards/single'

    If I head over to the url:
    /cards/1989/topps/baseball

    then echo $this->param('year')
    it yields: 1989/topps/baseball
    And all other params output 0.

    Any ideas whats happening here?
    I originally thought I could use a single route but I get missing pages if the urls dont match.

    Thanks
    Rich
  • HarroHarro
    Accepted Answer
    Routes are processed in the order in which they are defined.

    Like this, a URI like "/cards/1989/topps/baseball" will be matched by the first route, 'cards/:year'.

    Reverse them, always start with your most specific routes.

Howdy, Stranger!

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

In this Discussion