Edward Posted July 20, 2013 Share Posted July 20, 2013 I have a slight problem I want to be able to load items via name or numerical id, yii is already set to work with numerical id through '<controller:\w+>/<id:\d+>'=>'<controller>/view' but what if i pass a unique string instead to the view page how could i get that to work for example: mywebsite/item/babolat-aerodrive-2013-nadal-rafa-3 I have tried to make some of my own customizations but they have failed to work and i received the following error message: Error 404The system is unable to find the requested action "babolat-aerodrive-2013-nadal-rafa-3". Is there someone that may know how to deal with such a situation? Link to comment Share on other sites More sharing options...
Edward Posted July 21, 2013 Author Share Posted July 21, 2013 After some peaceful mediation: '<controller:item>/<id:\S+>'=>'item/view', As you can see this will strictly work for only the item controller and will not interfere with others. I also used \S because this means not whitespace, if I use /w it will cover all word characters but not the hypen "-" which I need. You also need to add pages in item you need to access in config/main.php routes otherwise the above route will always send you to the view page. 'item/create'=>'item/create', Have a nice weekend everybody! Link to comment Share on other sites More sharing options...
Larry Posted July 22, 2013 Share Posted July 22, 2013 Excellent. Kudos for figuring that out and thanks for sharing. Here's to peaceful meditation! Link to comment Share on other sites More sharing options...
Recommended Posts