在我的CakePHP應用程序連接了以下路線:CakePHP的2.x的反向路由鏈路助手
Router::connect('/:city/dealer/:id',
array('controller' => 'dealers', 'action' => 'view'),
array(
'pass' => array('city', 'id'),
'city' => '[a-z]+',
'id' => '[0-9]+'
)
);
這個偉大的工程,使:domain.com/washington/dealer/1
但如何在視圖中爲此URL生成適當的HTML鏈接?如果我只是這樣做:
echo $this->Html->link(
'Testlink',
array('washington', 'controller' => 'dealers', 'action' => 'view', 1)
);
它增加了所有PARAMS到生成的鏈接的結尾:
http://domain.com/dealers/view/washington/1
我該如何正確做到這一點?
如果你使用會發生什麼「/:城市/:控制器/:id'你的路線?你想讓其他控制器使用相同的模式嗎? –
當我使用'/:city /:controller /:id'時,Cake抱怨domain.com/washington/dealer/1丟失的DealerController ... 基本上只有這個控制器在應用程序中... – Sebastian
嘗試domain.com/華盛頓/經銷商/ 1(注意經銷商) –