Set multiple router for same controller in zend framework

437 views Asked by At


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!!!

1

There are 1 answers

0
Tim Fountain On

You need to give the routes different names, e.g.:

$router->addRoute('services', $route);

[...]

$router->addRoute('servicesArticle', $routeServiceArticle); 

Then it should work.