Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Getting URI for a Router
Purusothaman
December 2013
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.
Harro
December 2013
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.
Purusothaman
December 2013
I got the meaning of this now. Thans a ton.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
December 2013
Purusothaman
December 2013