我的问题是如何使用 Zend_Controller_Router_Route_Chain 链接多个路由?
例如,我想为年/月/日链接 3 条路线,但 gole 是:
当 url 是 example.com/2011 运行索引控制器,年份操作 example.com/2011/11 运行索引控制器,年月动作 example.com/2011/11/10 运行索引控制器,年月日动作
我正在尝试使用此代码:
$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/ 应用程序向我显示年月日操作时,页面上有
注意:未定义索引:第 299 行 P:\Zend\ZendServer\share\ZendFramework\library\Zend\Controller\Router\Route.php 中的日期
也许我做错了什么。请帮我解决我的问题。谢谢。