3

路由中的多控制器如何工作?我的路线:

$router->addRoute(
       'index',
       new Zend_Controller_Router_Route('/:lang/:@action',
           array(
                'lang' => 'en',
               'module' => 'default',
               'controller' => 'index',
               'action' => 'index'
           )
       )
    );

此路由适用于索引控制器,但不适用于身份验证控制器。如何使用该路由和索引身份验证控制器?

我的菜单项:

$this->url(array('controller'=>'Auth','action'=>'index')

这个菜单项,不起作用。我的完整函数 _initRoutes()

protected function _initRoutes(){

    $frontController = Zend_Controller_Front::getInstance();
    $router = $frontController->getRouter();
    $router->removeDefaultRoutes();
    $router->addRoute(
            'fullRoute',
            new Zend_Controller_Router_Route('/:lang/:module/:controller/:action',
                    array('lang' => ':lang')
            )
    );
    $router->addRoute(
            'languageControllerAction',
            new Zend_Controller_Router_Route('/:lang/:controller/:action',
                    array('lang' => ':lang')
            )
    );

    $router->addRoute(
       'index',
       new Zend_Controller_Router_Route('/:lang/:@action',
           array(
                'lang' => 'en',
               'module' => 'default',
               'controller' => 'index',
               'action' => 'index'
           )
       )
    );

}

我需要控制器身份验证操作的路线。

4

1 回答 1

0

路线#1

这将指向http://yoursite.com/auth模块default, AuthController, indexAction:

$router->addRoute(
       'auth',
       new Zend_Controller_Router_Route(
           'auth',
           array(
               'lang' => 'en',
               'module' => 'default',
               'controller' => 'auth',
               'action' => 'index'
           )
       )
);

路线#2

这将指向http://yoursite.com/模块default, AuthController, indexAction:

$router->addRoute(
       'index',
       new Zend_Controller_Router_Route(
           '',
           array(
               'lang' => 'en',
               'module' => 'default',
               'controller' => 'auth',
               'action' => 'index'
           )
       )
);
于 2012-09-08T22:54:32.633 回答