###What happened:
- A link method call does not return the expected result (the correct path)
The following code
{{{
$this->html->link('Show', array('action' => 'show', 'id' => $model->_id));
}}}
returns the current path:
http://localhost/controller/index or http://localhost/controller/
###What was expected:
- when an id is supplied, the path is not set correctly. when the id is not supplied, the path is ok (the action is correct).
The following code
{{{
$this->html->link('Show', array('action' => 'show'));
}}}
returns the current path:
http://localhost/controller/show/
###Additional Infos
It should be no problem to supply a hardcoded string as a path, but i suppose it should work with an array too?
System is Ubuntu Linux with Cherokee-Setup as described in the tutorial. The id comes from mongo. (It doesnt work with an hard-coded id too).
kind regards,
mike
Id is an argument in url so You have to put it into ```args``` array: {{{ <?=$this->html->link($post->title, array('action' => 'show', 'args'=> array('id' => $post->_id)));?> }}}lithium_mongo uses the same syntax, so maybe its actually a bug? http://rad-dev.org/lithium_mongo/source/views/elements/collections.html.php {{{ $this->html->link($collection, array('controller' => 'collections', 'action' => 'view', 'id' => $collection)); }}}It has to do with this route where the regex is not reverse properly. {{{ Router::connect('/{:controller}/{:action}/{:id:[0-9]+}'); }}} Using the route below should work. {{{ Router::connect('/{:controller}/{:action}/{:id}'); }}}When i change the route as suggested, the show, edit and delete routes work perfectly, but a simple add without the id doesnt work (i get redirected to my default route which is an index method) Defined Routes: {{{ Router::connect('/{:controller}/{:action}/{:id}.{:type}', array('id' => null)); Router::connect('/{:controller}/{:action}/{:id}'); Router::connect('/{:controller}/{:action}/{:args}'); }}} My Links: {{{ <?= $this->html->link('Add New', array('controller' => 'defis', 'action' => 'add')); ?> <?= $this->html->link($this->html->image('admin/show.png', array('alt' => 'Show', 'title' => 'Show')), array('action' => 'show', 'id' => $defi->_id), array('escape' => false)); ?> <?= $this->html->link($this->html->image('admin/edit.png', array('alt' => 'Edit', 'title' => 'Edit')), array('action' => 'edit', 'id' => $defi->_id), array('escape' => false)); ?> <?= $this->html->link($this->html->image('admin/delete.png', array('alt' => 'Delete', 'title' => 'Delete')), array('action' => 'delete', 'id' => $defi->_id), array('escape' => false)); ?> }}} {{{ Current Page: domain.tld/defis/index Add: domain.tld/defis/add Edit: domain.tld/defis/edit/<HASH> Show: domain.tld/defis/show/<HASH> Delete: domain.tld/defis/delete/<HASH> }}} All links point to the correct route, but when i click the add link i come back to my index page (from where i execute these links). The other three links work as requested.