1
votes

My apologies for the title of this question not being very descriptive but the truth is I'm not too sure what the correct terminology for this question is. I am new to using Zend Framework.

Imagine this url: www.foo.com/bar The code below takes "bar" and passes it through to the index controller's load action. However I have another controller called "mypresentation" which is getting ignored now the router below has been added to the Bootstrap.

$route = new Zend_Controller_Router_Route(
    '/:prospect',
    array('controller'=>'index', 'action' => 'load'));

$router->addRoute('load', $route);

How to I make the router ignore hardcoded controllers ?

Any help is much appreciated and I'll change the title if I can when I have more information.

Alex.

FIX:

$prospectRoute = new Zend_Controller_Router_Route(
    '/:prospect',
    array('controller'=>'index', 'action' => 'load')
);

$route2 = new Zend_Controller_Router_Route(
    'mypresentation',                        
     array('controller' => 'mypresentation') 
);

$router->addRoute('index', $prospectRoute);
$router->addRoute('mypresentation', $route2);      
1
So you want the default routes + this one custom route (as a basic catch-all)? The problem is your defined route intercepts all '/whatever' first... Maybe it can be chained to match after the default routes are checked.Darryl E. Clarke
I have tried making it chain to match after the defaults but with no luck. You understand the question though :)beingalex

1 Answers

1
votes

Add another route before this one, to catch any routes to the mypresentation controller first. It runs through the routes in order till it finds the first one it matches.

$route2 = new Zend_Controller_Router_Route(
    'mypresentation',                        // what's typed in URL
     array('controller' => 'mypresentation') // send here
);

$router->addRoute('mypresentation', $route2);
$router->addRoute('load', $route);           // Your original route

If you want to catch all controllers, use

$route3 = new Zend_Controller_Router_Route(
    ':controller',                       
     array('controller' => ':controller')
);