0
votes

It can't correct route from the following:

Router::connect('/ctl/act/subact/:mode/:sort'       
, array('controller' => 'ctl', 'action' => 'act_subact',
'mode' => null , 'sort' => null));

--

$html->link('go',array('controller'=>'ctl','action'=>'act_subact'))

--

<a href="/ctl/act_subact/">go</a>

How can I do? Env:CakePHP 1.3.6 php5.2.5 on apache2

1

1 Answers

2
votes

The Route /ctl/act/subact/:mode/:sort means that there must be a :mode and :sort parameter. This route would not match the URL /ctl/act/subact/. If there are optional parameters, you need to denote those with an asterisk: /ctl/act/subact/*. This route would match the URLs /ctl/act/subact/, /ctl/act/subact/foo and /ctl/act/subact/foo/bar.

If you need these optional parameters as named parameters, you'll need to create several routes for each possible "length":

Router::connect('/ctl/act/subact/:mode/:sort', array('controller' => 'ctl', 'action' => 'act_subact', 'mode' => null, 'sort' => null));
Router::connect('/ctl/act/subact/:mode', array('controller' => 'ctl', 'action' => 'act_subact', 'mode' => null));
Router::connect('/ctl/act/subact/', array('controller' => 'ctl', 'action' => 'act_subact'));