如何在cakephp中订购不同页面的链接

时间:2015-03-28 15:40:09

标签: php cakephp controller cakephp-2.3

我想弄清楚如何组合这些链接以便有用。 通常在cakePhP我创建新页面,它像这样链接到彼此。     soemthing.com/Places/catergory 但我希望它看起来像这个地方/类别/ {地名} / {服务类型的身份}

所以在我的蛋糕php控制器中我写了这个

     public function category($city){



    $data = array('place' => $city);
    $this -> set('services',$this -> Service -> find('all', array('conditions' => array('Service.place' => $city))));
    $this -> set($data);

    }

但它没有用,所以任何人都对此有任何想法,需要帮助, 我是新来的蛋糕PHP,所以假装你回答初学者。

1 个答案:

答案 0 :(得分:0)

像这样的东西

public function category($city=null,$type=null){
    $conditions = array('Service.place' => $city,'Service.type' => $type);
    $services = $this -> Service -> find('all', array('conditions' => $conditions)));
    $this -> set(compact('services','city');
}

routes.php文件

Router::connect('/places/category/*', array('controller'=>'services','action'=>'category'));