Zend Framework - 重定向到不同模块中的 IndexController
所有,
我在 Zend 的 mvc 框架中有以下项目设置。访问应用程序后,我希望用户重定向到“移动”模块,而不是转到“默认”模块中的 IndexController。我该怎么做?
-billingsystem
-application
-configs
application.ini
-layouts
-scripts
layout.phtml
-modules
-default
-controllers
IndexController.php
-models
-views
Bootstrap.php
-mobile
-controllers
IndexController.php
-models
-views
Bootstrap.php
Bootstrap.php
-documentation
-include
-library
-logs
-public
-design
-css
-images
-js
index.php
.htaccess
我的index.php有以下代码:
require_once 'Zend/Application.php';
require_once 'Zend/Loader.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
All,
I have the following project setup in Zend's mvc Framework. Upon accessing the application, I want the user to redirect to "mobile" module instead of going to IndexController in "default" module. How do I do that?
-billingsystem
-application
-configs
application.ini
-layouts
-scripts
layout.phtml
-modules
-default
-controllers
IndexController.php
-models
-views
Bootstrap.php
-mobile
-controllers
IndexController.php
-models
-views
Bootstrap.php
Bootstrap.php
-documentation
-include
-library
-logs
-public
-design
-css
-images
-js
index.php
.htaccess
My index.php has the following code:
require_once 'Zend/Application.php';
require_once 'Zend/Loader.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有两个选择:
1- 通过编辑 application.ini 文件将
mobile
设置为应用程序的默认模块resources.frontController.defaultModule = "mobile"
2-您可以创建一个插件来拦截每个请求并转发到相同的控制器和操作,但转发到移动模块
,并且不要忘记添加错误控制器到 if 子句,这样当应用程序抛出错误时,您就不会陷入神秘的循环,就是这样
you have two options :
1- set
mobile
as default module for your application by editing your application.ini fileresources.frontController.defaultModule = "mobile"
2- you can create a plugin that intercept every request and forward to the same controller and action but to the mobile module
and don't forget to add the error controller to the if clause so you don't end up with mysterious loop when your application throws an error , and that is it
在控制器中,您可以使用
例如:
这将转到索引操作,移动模块的索引控制器,您也可以使用
null
:传递
null
将使用当前的操作和控制器。希望有帮助。
From within a controller you you can use
For example:
This would go to the index action, index controller of the mobile module, you can also use
null
:Passing
null
will use the current action and controller.Hope that helps.