CakePHP: How to map named params correctly on custom routes

Assume you are using the following route

Router::connect('/:language/:controller/:action/*', array (), array ());

in a multi-language CakePHP installation as the only rule in the routes.php and still

$url = Router::url(array('controller'=>'example','action'=>'index','language'=>'en','show_all'=>'true')); 

yields

'/example/index/language:en/show_all:true'

instead of

'/en/example/index/show_all:true'

Note that

$url = Router::url(array ('controller'=>'example','action'=>'index','language'=>'en'));

works correctly (gives '/en/example/index/').

So the problem only exists with named parameters.

The simple solution is to state

Router::connectNamed(array('show_all'));

Fabian Gebert

2009/01/13 22:46

Technology

Add comment