I have this routing
$router->addRoute('clinics',
new Zend_Controller_Router_Route('clinics/:clinicPath', array('controller' => 'clinics', 'action' => 'view')),
new Zend_Controller_Router_Route('clinics/create', array('controller' => 'clinics', 'action' => 'create1')));
And i want to create clinic (do the createAction) if i go 'clinics/create' and view clinic if im going something else (ex. 'clinic/happyTooth').
Now on an开发者_开发知识库y link rise View event. How to change this? thx.
I think you need to add rule on your route, try:
new Zend_Controller_Router_Route('clinics/:clinicPath',
array('controller' => 'clinics', 'action' => 'view'),
array('clinicPath' => '(?!create)[a-z\-0-9^.]+')),
I guess the simplest way is to use the magic __call function of the ClinicsController and do a method call matching there (and use the default route).
You are not calling addRoute($name, $route)
properly. You should either call it twice (once per route), or call addRoutes(array($route1, $route2))
. This is likely the cause of your problem.
Routes are matched in reverse order, so your order is correct. "create" is specific, so you want it at the bottom of the list, so it is matched before the dynamic route above it.
精彩评论