Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Getting URI for a Router
  • I have an action which works fine with the URI which looks like "categories/view/6"

    I am changing the code to user the "name" in the URI instead of "id" like "category/php"

    I am having the below routes defined in routes.php file in config section.

    return array(
        'category/(:name)' => 'categories/view/$1'
    );

    In the controller, I am trying to get the url as below and it returns only space. What I am doing wrong?

    Router::get('category', array('$1' => $category->name));

    I tried all solutions from http://fuelphp.com/docs/general/routing.html and http://fuelphp.com/docs/classes/router.html . I believe I am missing something silly to understand.

  • HarroHarro
    Accepted Answer
    get() only works with named routes, so you need to define it as

    return array(
        'category/(:name)' => array('categories/view/$1', 'name' => 'category'),
    );

    otherwise it can't be found.
  • I got the meaning of this now. Thans a ton.

Howdy, Stranger!

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

In this Discussion