views:

31

answers:

2

I would like to keep the old default Zend Router, and just add a router for administration subpages since the controllers are growing in size and I would like to logically separate them a little as well as have cleaner URLs.

The documentation seems to explain how to do other things but not this...

+1  A: 

I don't know if its possibile to do it with an Underscore and the upcase user, sorry, but without you had to add the following to your bootstrap.php

$ctrl  = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();

$route['admin_users'] = new Zend_Controller_Router_Route_Regex(
    'administration/users',
    array(
        'controller'    => 'administrationusers',
    )
);

$router->addRoute('admin_users_route',   $route['admin_users']);

note: in this scenario your controller is:

class AdministrationusersController extends Zend_Controller_Action
{
        // stuff
}
Hannes
As no regex is involved, I would use Route_Static instead
Ashley
So I would have to create a separate route for every single separate Administration controller?
lhnz
@Ashley you are right, just had that at hand :) @Ihnz well via regex you can for example grap the "user" part from the url and set it as controller, but you can not combine it with anything as far as i know. You could set up an Administration Module and make Users an Controller of it, then use a route like `$route['admin_users'] = new Zend_Controller_Router_Route_Regex( 'administration/([\w]+)', array( 'module' => 'administration' ), array( 1 => 'controller', ));`
Hannes
I'd suggest module, but if you don't want a module what about chaining it: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.chain
Ashley
+2  A: 

This will work out of the box with the default routes. You just need to add an administration module, and then /administration/users will map to the users controller in the administration module.

Tim Fountain
Yep, it can be accomplished with a modular-structure.
faileN
(Just noticed you answered my other question too. Thanks for spreading your Zend knowledge... :) )
lhnz