在CakePHP应用程序和Html-Helper中使用路由来隐藏url参数时,隐藏/index操作的正确方法是什么?
我希望能够在使用helper时显示像/books/2这样的urls
echo $this->Html->link('Books', array(
'controller'=>'books', 'action'=>'index', 2
));在我的routes.php中尝试了以下内容
Router::connect('/books/:id', array('controller' => 'books'), array(
'id' => '[0-9]+',
'pass' => array('id')
));输出为:http://www.example.com/books/index/2
招聘对象:http://www.example.com/books/2
发布于 2012-08-09 02:54:12
在创建链接时,您需要在路由数组中使用id键:
echo $this->Html->link('Books', array(
'controller'=>'books', 'action'=>'index', 'id' => 2
));https://stackoverflow.com/questions/11868473
复制相似问题