2012-08-17 64 views
0

我正在抓住蛋糕的路由,但在差異顯示一個表中的數據時遇到問題。觀點。CakePHP路由和按ID顯示數據

我有一個由news_type_id標記的文章的新聞表。 我有每個路由設置爲顯示視圖調用requestAction並按特定的news_type id列出新聞文章。

//--index of news articles with news_type_id = 1 
/section1/ 

//--index of news articles with news_type_id = 2 etc 
/section2/ 

我的路線是建立這樣的:

Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', 'section1')); 

但問題很快是因爲我嘗試:

Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', 'section1')); 
Router::connect('/section2', array('controller' => 'pages', 'action' => 'display', 'section2')); 

...當然的行動路線回到頂端路線(SECTION1)。

有人能指出我對此明顯嗎?

回答

0

我會嘗試:

Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', array('mysection'=>'section1'))); 
Router::connect('/section2', array('controller' => 'pages', 'action' => 'display', array('mysection'=>'section2'))); 

,並在行動我會得到mysection作爲參數

希望能幫助

問候