我正在CakePHP 2.0中重建一個站點,並需要將一些舊URL路由到新路徑。例如,這樣的:CakePHP 2.0路由器::連接如何傳遞命名參數
http://www.example.com/widget/helpbox/location/mackay-qld
將路由到這一點:
http://www.example.com/widgets/answer/location_id:10542
爲了做到這一點,我有以下途徑:
Router::connect(
'/widget/helpbox/location/mackay-qld',
array(
'controller' => 'widgets',
'action' => 'answer',
'location_id' => 10542
)
);
當我調試$ this-> request-> params,我得到這個:
Array
(
[plugin] =>
[controller] => widgets
[action] => answer
[named] => Array
(
)
[pass] => Array
(
)
[location_id] => 10542
[isAjax] =>
)
但我相信這一點:
Array
(
[plugin] =>
[controller] => widgets
[action] => answer
[named] => Array
(
[location_id] => 10542
)
[pass] => Array
(
)
[isAjax] =>
)
我也打過電話
Router::connectNamed(array('location_id'));
...但無濟於事。 location_id仍然以相同的方式傳遞 - 而不是一個命名參數。
有誰知道正確的語法?
這可能是一個錯誤。考慮詢問/報告給Cake2傢伙。分別是http://ask.cakephp.org/和http://cakephp.lighthouseapp.com/dashboard。 – sibidiba 2012-02-11 12:33:20