我有一個名爲Items的控制器,另一個叫Categories。項目可能屬於不同的類別。Cakephp嵌套路線
,我有途徑是
/items
/items/:item_id
/items/categories
/items/categories/:category_id
這是我的routes.php文件
Router::connect('/items', array('controller' => 'items', 'action' => 'index');
Router::connect('/items/:item_id', array('controller' => 'items', 'action' => 'view'), array('pass' => array('item_id')), array("item_id" => "[0-9]+"));
Router::connect('/items/categories', array('controller' => 'categories', 'action' => 'index'));
Router::connect('/items/categories/:category_id', array('controller' => 'categories', 'action' => 'view', array('pass' => array('category_id')), array("category_id" => "[0-9]+"));
的問題是,第三路由失敗,因爲它路由到項目控制器,它不該」噸。
我該如何解決這個問題?
非常感謝。它完成了這項工作。 – 2011-04-10 09:19:07
你通常希望從最貪婪的(最確切的)到最貪婪的列舉它們(例如/ * [catch all]幾乎永遠不會成爲第一條路線,而是有最後一個位置) – dogmatic69 2011-04-10 20:56:13