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
也許我做錯了什麼。請幫我解決我的問題。謝謝。