开发者

Zend Framework - Regex Routes and Url View Helper Issue

开发者 https://www.devze.com 2023-01-10 07:14 出处:网络
I have this route setup in one of my bootstrap files... $route = new Zend_Controller_Router_Route_Regex(

I have this route setup in one of my bootstrap files...

$route = new Zend_Controller_Router_Route_Regex(
    'user/(\d+)',
    array(
        'module'        => 'user',
        'controller'    => 'view',
        'action'        => 'index'
    ),
    array(
        1 => 'id'
    ),
    'user/%d'
);
$router->addRoute('user', $route);  

I am then trying to use the view url helper to buld a href but I keep getting the error 'Cannot assemble. Too few arguments?'.

This is the code for my helper that is generating the link:

$this->view->url(array('controller'=>'user', 'action' => $userID), 'user');  

If I take out the 'user' part of the url then it doesnt error but the link doesnt always display correctly.

I thought this was the name and should refer to the name I have entered under addRoute.

I have played with d开发者_如何学JAVAifferent settings but I continue to receive an error. Can anyone see where i am going wrong?

Thanks,

Martin


try this

$this->view->url(array('id' => $userId), 'user', true); 

do not need to supply controller/action again as it's defined in the route (second param), the third param (true) will reset the params from the current request.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号