Zend Controller Router传递变量

时间:2012-02-23 21:32:47

标签: php zend-framework bootstrapping

我想将/ market-research /转发到/ index / index / slide / 2

所以我想将此值传递给'slide'参数

    $routemr = new Zend_Controller_Router_Route_Static(
        'market-research',
        array('controller' => 'index', 'action' => 'index')
    );
    $router->addRoute('market-research', $routemr);

我该怎么做?感谢。

2 个答案:

答案 0 :(得分:4)

尝试以下方法:

 $router = $frontController->getRouter();
    $route = new Zend_Controller_Router_Route_Static(
            '/market-research',
        array(
            'controller' => 'index',
            'action'     => 'index',
            'type' => 'slide', //default value (im using 'type' just as an example)
            'id' => 2, //default value

        ));
    $router->addRoute('market-research', $route);

答案 1 :(得分:0)

这应该这样做:

$router = $this->_front->getRouter();
$route = new Zend_Controller_Router_Route(
    'market-research/',
    array(
        'controller' => 'index',
        'action' => 'index',
        'slide' => 2
    )
);
$router->addRoute('index-marketresearch', $route);