0
我的问题是如何使用Zend_Controller_Router_Route_Chain链多个路由?如何链接多个路由Zend_Controlle
比如我想链年/月/日 3条路线,但戈莱是:
when url is example.com/2011 runs index controller, year action example.com/2011/11 runs index controller, year-month action example.com/2011/11/10 runs index controller, year-month-day action
我想使用此代码:
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$chain = new Zend_Controller_Router_Route_Chain();
$route1 = new Zend_Controller_Router_Route(
':year',
array(
'controller' => 'news',
'action' => 'year'
)
);
$route2 = new Zend_Controller_Router_Route(
':month',
array(
'controller' => 'news',
'action' => 'year-month'
)
);
$route3 = new Zend_Controller_Router_Route(
':day',
array(
'controller' => 'news',
'action' => 'year-month-day'
)
);
$chain->chain($route1)
->chain($route2)
->chain($route3);
$router->addRoute('chain', $chain)
->addRoute('route3', $route3)
->addRoute('route2', $route2)
->addRoute('route1', $route1);
当我去以example.com/2012和example.com/2012/11/11一切都好
但是当我访问example.com/2012/11/应用程序显示我年年日行动和页面上有
Notice: Undefined index: day in P:\Zend\ZendServer\share\ZendFramework\library\Zend\Controller\Router\Route.php on line 299
也许我做错了什么。请帮我解决我的问题。谢谢。