In my CakePHP App I connected the following Route:
Router::connect('/:city/dealer/:id',
array('controller' => 'dealers', 'action' => 'view'),
array(
'pass' => array('city', 'id'),
'city' => '[a-z]+',
'id' => '[0-9]+'
)
);
This works great and enables: domain.com/washington/dealer/1
But how do I generate the proper HTML link in the View for this URL? If I just do this:
echo $this->Html->link(
'Testlink',
array('washington', 'controller' => 'dealers', 'action' => 'view', 1)
);
It adds all the params to the end of the generated link:
http://domain.com/dealers/view/washington/1
How do I do this properly?
$this->Html->link(Link, '/washington/dealers/'.$id.'');This seems to be really bad practice, since it all stops working should I change routes. I'd be glad if someone knew a better way. - Sebastian