我有这个路由器:
Router::connect
(
':renting/:model_name/:number_name/',
array('controller' => 'cars', 'action' => 'view'),
array(
'pass' => array('renting', 'model_name', 'number_name'),
'renting' => 'renting'
)
);
当我在视图中执行此操作时
$html->link("NAME",
array(
'controller' => 'cars',
'action' => 'view',
'renting',
$model_name,
$number_name
)
);
我在页面上获得此链接:mypage.com/cars/view/renting/mustang/03212xd
我需要获得mypage.com/renting/mustang/03212xd
我被困在这里。谢谢。注意:muypage.com/renting/mustang/03212xd
重定向到我的控制器功能,但在使用$html->link
功能时没有。
答案 0 :(得分:1)
如果您为参数命名,则需要为参数命名:
array(
'controller' => 'cars',
'action' => 'view',
'renting' => 'renting',
'model_name' => $model_name,
'number_name' => $number_name
)
如果:renting
始终为'renting'
,则无需对其进行参数化:
Router::connect('/renting/:model_name/:number_name/',
array('controller' => 'cars', 'action' => 'view', 'renting'),
array('pass' => array('model_name', 'number_name')));
$html->link(…, array(
'controller' => 'cars',
'action' => 'view',
'renting',
'model_name' => $model_name,
'number_name' => $number_name
));