简体   繁体   中英

Zend Custom Modules Routes

i have this set up:

    application
    ---admin
    -----controllers
    -------IndexController.php
    ---public
    -----controllers
    ---modules
    -----users
    -------controllers
    -----pages
    -------controllers

I'd like to have this routes :

www.domain.com/admin/modulename/controller/action/

or if module not exist i use admin controllers

www.domain.com/admin/controller/action/

Any suggesiton?

Thanks

In your bootstrap file write this code :

$router = Zend_Controller_Front::getInstance()->getRouter();
if($moduleName){
$route = new Zend_Controller_Router_Route(
                  ':module/:controller/:action/',
                  array(
                      'controller' => $ControllerName,
                      'module' => '$moduleName',
                      'action'     => $ActionName
                  )
              );
}else{
$route = new Zend_Controller_Router_Route(
                  ':controller/:action/',
                  array(
                      'controller' => $ControllerName,
                      'action'     => $ActionName
                  )
              );
}

$router->addRoute('default', $route);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM