On Sat, Apr 9, 2011 at 3:27 AM, ThunderTD <[email protected]> wrote:
> The custom route detailed in the CakePHP CookBook is working fine as
> long as it's used in one direction. Inside the routes.php file I'm
> using the following route:
>
> Router::connect('/:language/artists/:id',
> array('controller'=>'artists','action'=>'view'), array('pass' =>
> array('id'), 'language' => '[a-z]{3}','id' => '[0-9]{1}')); ,
>
> So I can accesss the View Action of the ArtistsController via
> http://xxx/artists/:id .
>
> But what about the reverse lookup. Shouldn't a call to $html-
>>link('Artist 2', array( 'controller' => 'artists', 'action' =>
> 'view', 2)) print out a link to http://xxx/artists/2 ? Instead it
> gives a link to http://xxx/artists/view/2.
>
> Is this expected behavior?
Yes. You need to pass your params like this:
$this->Html->link(
'Artist 2',
array(
'controller' => 'artists',
'action' => 'view',
'language' => 'fre',
'id' => 2
)
);
Notice that you'd forgotten language. Also, your route doesn't pass language.
Router::connect(
'/:language/artists/:id',
array(
'controller'=>'artists',
'action'=>'view'),
array(
'pass' => array(
'language',
'id'
),
'language' => '[a-z]{3}',
'id' => '[0-9]+'
)
);
I've also changed your regexp here for id. The way you had it, only
ids between 0 & 9 would match.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php