Reputation: 9076
I am trying to setup meaningful URLs such as http://www.site.com/company/department however it hammers my existing URLs which are in the Controller/Action shape.
In my bootstrap, I create my new route as follows:
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$route = new Zend_Controller_Router_Route(":company/:dpt", array('controller' => 'browse'));
$router->addRoute("browse", $route);
When I browse to http://www.site.com/ABC_Co/dry_goods it routes me to IndexAction in BrowseController. Great! The problem is that my other admin-related URLS - such as /company/create, etc - are directing there too.
Is there some way to get Zend to do its default Controller/Action matching first, and revert to the Browse route only on failure?
Thanks!
Upvotes: 4
Views: 947
Reputation: 2217
Routes are handled on LIFO, you'll need to do something like this:
$router->removeDefaultRoutes();
//add your routes
//add in the default route:
$route = new Zend_Controller_Router_Route(":module/:controller/:action"
Instead, you may just want to sonsider adding a "static" component to your "browse" route. That would make is more specific:
$route = new Zend_Controller_Router_Route("browse/:company/:dpt", array('controller' => 'browse'));
IMO, the second one is the better option
Upvotes: 5