Reputation: 547
How to set multiple router for the same controller,if we are facing with the different action in one controller?
I have two action in my controller services in admin module.
First action is manage and second is manageArticle
Here is my code
protected function _initRoutes(){
$this->bootstrap('FrontController');
$router = $this->getResource('FrontController')->getRouter();
$route = new Zend_Controller_Router_Route(
'admin/services/:actionType',
array('module' => 'admin',
'controller' => 'services',
'action' => 'manage'),
array('actionType' => '(add|edit)')
);
$router->addRoute('services', $route);
$routeServiceArticle = new Zend_Controller_Router_Route(
'admin/services/article/:actionType',
array('module' => 'admin',
'controller' => 'services',
'action' => 'manageArticle'),
array('actionType' => '(addArticle|editArticle)')
);
$router->addRoute('services', $routeServiceArticle);
}
Please help me
Thanks in advance!!!
Upvotes: 1
Views: 434
Reputation: 33148
You need to give the routes different names, e.g.:
$router->addRoute('services', $route);
[...]
$router->addRoute('servicesArticle', $routeServiceArticle);
Then it should work.
Upvotes: 1