設置我的路由的最佳方式是什麼,以便不同類型的帖子具有不同的URL?根據帖子類型路由到不同的URL
例如,正規職位/posts/slug
而精選文章是/featured/slug
都鏈接到同一個控制器和行動/posts/view/slug
。
我嘗試了不同的方法來做到這一點,但收效甚微。目前我鏈接參數看起來像下面這樣:
array('controller' => 'posts', 'action' => 'view', 'featured' ,$post['Post']['slug'])
編輯:我可以爲每個不同類型的操作,並使用setAction命令使用視圖操作來代替。雖然有更好的方法來做到這一點?
array('controller' => 'posts', 'action' => 'featured', $post['Post']['slug'])
function featured($slug) {
$this->setAction('view', $slug);
}