0
votes

I have this route set up, and manually entering the url works:

Router::connect('/:controller/:id/*',
    array('action' => 'view'),
    array('pass'=>array('id'), 'id' => '[0-9]+'));

However, with html->link, I can't generate a link without the action.

$this->Html->link('linkName', array(
    'controller' => 'controllerName',
    'action' => 'view',
    $id, $slug));

generates controllerName/view/id

$this->Html->link('linkName', array(
    'controller' => 'controllerName',
    $id, $slug));

generates controllerName/index/id

How can I generate the url controller/id with html helper?

Thanks!

1

1 Answers

0
votes

CakePHP needs specificity. Here, I had to specify the action and the id, then cake matched these attributes to the correct route and generated the correct url:

$this->Html->link('linkName', array(
    'controller' => 'controllerName',
    'action' => 'view',
    'id' => $id,
     $slug
));