1


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 Answer 1

1

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

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

[...]

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

Then it should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.