如何在Zend Framework中添加路由到这样的url / index / viewmodel / id / {id} /

时间:2014-10-03 14:58:27

标签: php zend-framework routes

我有这样的代码,但这并不费力

$route = new Zend_Controller_Router_Route_Static ('viewmodel', array (
    'controller' => 'Index',
    'action' => 'viewmodel'
));
$router->addRoute('viewmodel', $route);

P.S:工作代码

$routerTwo = Zend_Controller_Front::getInstance()->getRouter();
        $route = new Zend_Controller_Router_Route(':index/:viewmodel/:id', array (
            'controller' => 'index',
            'action' => 'viewmodel'
        ));
        $routerTwo->addRoute('viewmodel', $route);

1 个答案:

答案 0 :(得分:0)

试试

$route = new Zend_Controller_Router_Route('index/viewmodel/id/:id', array (
    'controller' => 'index',
    'action' => 'viewmodel'
));
$router->addRoute('viewmodel', $route);

在您可以访问的操作中:id $this->getRequest()->getParam('id');