【发布时间】:2012-03-14 07:19:40
【问题描述】:
我有一条路线:
Router::connect('/restaurants/*', array('controller'=>'restaurants', 'action' => 'view'));
当用户访问 site.com/restaurants/Seafood 时,他们会获得一份海鲜餐厅列表。好吧,问题是,现在我想在我的控制器中添加一个编辑功能,并且 site.com/restaurants/edit/4 路由到我的控制器的视图功能。如何告诉我的路线将 /restaurants/edit 发送到 edit() 函数?
我明白了贪婪之星是个坏主意,但我不知道如何在没有它的情况下使我的 view() 函数正常工作。这是我的视图代码:
public function view($type=null) {
$this->set('title', $type.' restaurants in and near Gulf Shores');
$this->paginate['Restaurant']=array(
'limit'=>9,
'order'=>array(
'id'=>'asc'
),
'joins' => array(
array(
'table' => 'cuisines_restaurants',
'alias' => 'CuisinesRestaurant',
'type' => 'inner',
'conditions'=> array('CuisinesRestaurant.restaurant_id = Restaurant.id')
),
array(
'table' => 'cuisines',
'alias' => 'Cuisine',
'type' => 'inner',
'conditions'=> array(
'Cuisine.id = CuisinesRestaurant.cuisine_id'
)
)
)
);
$this->set('restaurantType',$this->paginate($this->Restaurant, array('cuisine_type'=>$type)));
}
【问题讨论】:
标签: cakephp routes cakephp-2.0