What is the correct way to hide the /index
action while having url parameters using Routing in CakePHP apps and the Html-Helper?
I want to be able to show urls like /books/2
while using the HTML helper
echo $this->Html->link('Books', array(
'controller'=>'books', 'action'=>'index', 2
));
Tried the following in my routes.php
Router::connect('/books/:id', array('controller' => 'books'), array(
'id' => '[0-9]+',
'pass' => array('id')
));
Output is: http://www.example.com/books/index/2
Wanted is: http://www.example.com/books/2
You'll need to use the
id
key in the routing array when creating links: