zinbiel Posted August 31, 2009 Share Posted August 31, 2009 Hello phpfreaks! I'm currently trying to recode my own libraries using the Zend framework. This is my problem: By default Zend (the dispatcher?) upon access of let's say http://localhost/A/test is trying to Find an action 'testAction' in the 'A' controller. This is fine for the public portion of my websites. However I'd like to use a different path parsing technique for the administrator interface: I have created an AdminController which takes care of the login part. When someone authenticates I want them to be redirected to /admin/user/view and this url to be parsed as an action listAction in the UserController and not as userAction in AdminController. Right now I'm using the redirector helper and I can forward it to the proper url with $front=Zend_Controller_Front::getInstance(); $front->setBaseUrl('/admin/'); $this->_helper->redirector('view','User'); However I'd then have to rewrite the route for each class and action inside the /admin/ path which sounds wrong. In addition to that, by simply rerouting let's say /admin/user/view to call viewAction in UserController the url helper seems to be still outputing /user/view. I would like to fix that as well so some Controllers' urls are looked for in /admin/ instead. Can someone advice on a clean way to solve this? Quote Link to comment https://forums.phpfreaks.com/topic/172557-zend-admin-path-routing/ Share on other sites More sharing options...
zinbiel Posted September 9, 2009 Author Share Posted September 9, 2009 I'll answer this myself for anyone interested as I've solved it and moved way past it. In my bootstrap file I've reconfigured routing as such: $ctrl = Zend_Controller_Front::getInstance(); $router = $ctrl->getRouter(); For the login/logout function I wanted that handled by the AdminController and actions loginAction, logoutAction so: $router->addRoute( 'admin_login', new Zend_Controller_Router_Route('Admin/login', array('controller'=>'Admin','action'=>'login')) ); $router->addRoute( 'admin_logout', new Zend_Controller_Router_Route('Admin/logout', array('controller'=>'Admin','action'=>'logout')) ); For the rest of the actions I wanted every remaining url in the admin area handled by seperate controllers. This is done like this: $router->addRoute( 'Admin_generic', new Zend_Controller_Router_Route('Admin/:controller/:action/*', array('module'=>'default')) ); Quote Link to comment https://forums.phpfreaks.com/topic/172557-zend-admin-path-routing/#findComment-915264 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.