Richard Parnaby-King
Richard Parnaby-King

Reputation: 14862

Zend Route in a route

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')
    );

Upvotes: 2

Views: 314

Answers (1)

Sinisa Valentic
Sinisa Valentic

Reputation: 552

You should use route chaining.

I use it a lot, very powerful ...

Zend Controller Router - Chains

Upvotes: 2

Related Questions