Add Zend_Controller_Router_Route replaced default route
-
13-07-2021 - |
Question
When I added this route
$classes_router = new Zend_Controller_Router_Route(
'/:filter1/:filter2/*',
array(
'module' => 'course',
'controller' => $filter_controller,
'action' => 'index',
'filter1' => '',
'filter2' => ''
)
);
Te default route :module/:controller/:action
doesn't work anymore. Please tell me what is the problem?
Solution
The problem is that a request to somemodule/somecontroller/someaction
will be matched by the route you've added (which will be checked before the default one). You need to provide some restriction in the route to determine what it matches, perhaps by limiting the possible matches for the :filter1
variable:
$classes_router = new Zend_Controller_Router_Route(
'/:filter1/:filter2/*',
array(
'module' => 'course',
'controller' => $filter_controller,
'action' => 'index',
'filter1' => '',
'filter2' => ''
), array(
'filter1' => '(value1|foo|somethingelse)'
)
);
or adding a static prefix:
$classes_router = new Zend_Controller_Router_Route(
'/filter/:filter1/:filter2/*',
array(
'module' => 'course',
'controller' => $filter_controller,
'action' => 'index',
'filter1' => '',
'filter2' => ''
)
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow