2008年8月4日星期一

Re: [fw-mvc] Routing Trouble

2008/4/3 Hector Virgen <djvirgen@gmail.com>:
Basicly, you should add your search AFTER the :username one, as they
are matched in reverse order. Also, the
reqs.username part is wrong, I think. This is a regular expression.
Also, feel free to make the search route static
(Zend_Controller_Router_Route_Static).

Regards,
Emil Ivanov

> Hello,
>
> I am having some trouble creating a particular route. I am using a .ini
> file.
>
> What I am trying to do is route /members/:username to a profile controller
> in the members module. That works fine.
>
> But I also want certain paths like /members/search to use the default route
> so that it will route to the search controller of the members module. That's
> where I'm having trouble.
>
> I've tried adding a requirement that the "username" part of the route cannot
> match the string "search", but it seems to break the route entirely. Trying
> to access /members/foo now throws an error stating that the foo controller
> was not found, when it should be routing to the profile controller and
> displaying the "foo" profile.
>
> Here's my route:
>
> routes.profile.type = "Zend_Controller_Router_Route"
> routes.profile.route = "members/:username"
> routes.profile.defaults.module = "members"
> routes.profile.defaults.controller = "profile"
> routes.profile.defaults.action = "view"
> routes.profile.defaults.username = ""
> routes.profile.reqs.username = "!(search)"
>

--
My place to share my ideas:
http://vladev.blogspot.com

没有评论: