domin.com/products/mobile/3
我想这样做像cakephp
对于产品ID,我想这样显示:domain.com/3
domian.com/products/nokiamobiles
至domain.com/nokiamobiles
class productsController extends AppController{
public function mobile($id){
$this->set('nokia',$this->Product->findById($id));
}
public function nokiaMobiles(){
$this->set('nokia',$this->Product->find('all'));
}
}
答案 0 :(得分:0)
路线第一个:
Router::connect(
'/:id',
'controller' => 'products', 'action' => 'mobile',
array('id' => '[0-9]+')
);
第二名:
Router::connect(
'/nokiamobiles',
array('controller' => 'products', 'action' => 'nokiamobiles')
);
了解更多CakePHP Routes