How to change the default action of the index controller zend

早过忘川 提交于 2019-12-31 03:56:04

问题


I have just created a new Zend project. I want to use the setDefaultAction to change the default action of the Index controller to any other action of the Index controller. I know that I need to code something like :

$front = Zend_Controller_Front::getInstance();
$front->setDefaultAction("about");

but in what function I need to code this? Do I need to do something else?


回答1:


You could do this in your config

; application.ini
resources.frontController.defaultAction = "about"

Mind you, this will set the default action for all controllers.

An alternative option would be to set a static route for the home page (/), eg

; application.ini
resources.router.routes.home.type = "Zend_Controller_Router_Route_Static"
resources.router.routes.home.route = "/"
resources.router.routes.home.defaults.module = "default"
resources.router.routes.home.defaults.controller = "index"
resources.router.routes.home.defaults.action = "about"


来源:https://stackoverflow.com/questions/5359561/how-to-change-the-default-action-of-the-index-controller-zend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!