如何更改索引控制器 zend 的默认操作 [英] How to change the default action of the index controller zend

查看:32
本文介绍了如何更改索引控制器 zend 的默认操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个新的 Zend 项目.我想使用 setDefaultAction 将索引控制器的默认操作更改为索引控制器的任何其他操作.我知道我需要编写如下代码:

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?

推荐答案

你可以在你的配置中做到这一点

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"

这篇关于如何更改索引控制器 zend 的默认操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆