Welcome to WebmasterWorld Guest from 18.207.136.184

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

ZF Routing Insanity

i can route, but what about all my actions?

     
3:21 am on Sep 21, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 25, 2004
posts: 161
votes: 0


i have a controller with several actions:

user/add
user/edit
user/delete
user/view

i set up routing so that user/randomusername would redirect to user/view

but now if i type any of the other 3 actions into the url, it goes to user/view!


$FrontController = Zend_Controller_Front::getInstance();
$Router = $FrontController->getRouter();

$Router->addRoute("viewuser", new Zend_Controller_Router_Route(
"user/:username", array (
"username" => "Spongebob",
"controller" => "user",
"action"=> "view"
)));

surely i dont have to add routes for the other actions? they worked fine before i added this....
10:51 am on Oct 5, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


Anybody using Zend Framework that can lend a hand here?
3:25 pm on Oct 5, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 25, 2004
posts: 161
votes: 0


Issue: Routing rule will not allow localhost/artist/new to load
Reason:
In chapter 3 I asked you to add in the routing rule artist/:artistName. When the system encounters the pattern artist/new, the system will think “new” is the artistName.
Fix:
Update the routing rule to ‘artist/profile/:artistName’ the complete Zend_Route should be as shown below:
$Router->addRoute("artistprofile",
new Zend_Controller_Router_Route(
"artist/profile/:artistname",
array("artistname" => "The Smiths",
"controller" => "artist",
"action" => "profile"))

So unlike site/user (which won't work)
You now use siteprofile/user

Which I don't like so much, but hey it works!
Again, if you REALLY want the first option you must explicitly declare all the other actions :-s

All the best amigo!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members