Thanks Matt.
I create route like this:
routes.x.type = "Zend_Controller_Router_Route_Regex"
routes.x.route = "(.*)"
routes.x.defaults.module = "default"
routes.x.defaults.controller = "section"
routes.x.defaults.action = "load"
routes.x.map.1 = "path"
For uri like /about/history/1999/
I get output like:
array(4) {
["path"] => string(2) "about/history/1999"
["module"] => string(7) "default"
["controller"] => string(5) "section"
["action"] => string(5) "load"
}
So it is fine, I can easily load appropriate site section (section: about,
subsection: history, subsubsection: 1999).
But if I have a defined controller like subscription, or different module
like admin I can`t use them. I could redirect to it from within
SectionController::loadAction where every request goes but it isn`t the best
solution I believe.
I was thinking about plugin which could decide if additional routing is
needed or maybe custom route but (in both options) at the moment when routes
are loaded I guess front controller methods like getModuleName or
getControllerName don`t exist or return null. So I`m not sure how could I
make this decision (if controller exists load it, else use route regex like
"(.*)".
How it should be done?
@edit
looking at the errorHandler plugin I see that this approach could also be
used:
switch ($exceptionType) {
case 'Zend_Controller_Dispatcher_Exception':
$error->type = self::EXCEPTION_NO_CONTROLLER;
break;
So I could write similar plugin for this or basically use
ErrorController::errorAction to handle the logic for retriving section from
db. However, I don`t know if this plugin (errorAction method) was designed
to play such role.
I could also try to catch dispatch exception in my app index.php file like
this:
$fc = Zend_Controller_Front::getInstance();
try {
$fc->dispatch();
} catch (Zend_Controller_Dispatcher_Exception $e) {
// create router with additional route "(.*)"
$fc->setRouter($router);
$fc->dispatch();
} catch (Exception $e) {
// ...
}
However, I don`t know if this approach is recommended because according to
quickstart tutorial I guess front controller configuration (and other config
as well) should be in bootstrap file. Index.php should only launch dispatch.
Again, what`s your opinion?
--
View this message in context:
http://www.nabble.com/Friendly-URLs-tp6055801p20808404.html
Sent from the Zend Framework mailing list archive at Nabble.com.