views:

42

answers:

1

In my bootstrap file, I have a heck of a lot of routes. Is there a way to use a previous route as part of a new route?

For example, if I want to change the url structure of route 'admin', instead of changing it 30 times for all the other routes, can I just include the route 'admin' in front of everything else? Something like:

$router->addRoute(
    'admin',
    new Zend_Controller_Router_Route('/admin',
    array('controller' => 'index',
        'action'    => 'index',
        'module'    => 'default')
    )
    ->addRoute(
    'adminPage',
    new Zend_Controller_Router_Route($router->getRoute('admin') . '/somepage',
    array('controller' => 'index',
        'action'    => 'somepage',
        'module'    => 'default')
    );
+2  A: 

You should use route chaining.

I use it a lot, very powerful ...

Zend Controller Router - Chains

Sinisa Valentic
Thanks. Just what I was looking for =)
Dickie