[英]How to alter Zend Modules from outside their folder?
i'd like to change the views of certain zend modules, without altering their code.我想更改某些 zend 模块的视图,而不更改它们的代码。 My idea is to change the view folder for a module using the configuration (application.ini) and nothing else.
我的想法是使用配置(application.ini)更改模块的视图文件夹,仅此而已。
Is that possible?那可能吗?
How else to work with modules?如何使用模块? If you can't alter them from outside, the interchangeability kind of drops innit?
如果你不能从外部改变它们,那么互换性就会下降吗?
I guess you have:我猜你有:
YourModule
- controllers
- views
- alternativeViews
and you want to switch from views
to alternativeViews
?并且您想从
views
切换到alternativeViews
视图? You could use $view->addScriptPath('/path/to/app/views');
你可以使用
$view->addScriptPath('/path/to/app/views');
or add another scriptPatch
in your application.ini
.或在您的
application.ini
中添加另一个scriptPatch
。 However, I really disadvice from this (doing this too often will take way too long).但是,我真的不建议这样做(经常这样做会花费太长时间)。
In my opinion, this is the controller's job to decide.在我看来,这是控制器的工作来决定。 Thus you safe the view to use somewhere in your application (can be
application.ini
as well) and render a different view in your controller:因此,您可以保护在应用程序中使用的视图(也可以是
application.ini
)并在 controller 中呈现不同的视图:
public function indexAction()
{
// decide which view to render, save name of view in $viewName
$this->render($viewName);
}
using this file-structure:使用这个文件结构:
YourModule
- controllers
- views
- scripts
- yourController
- index.phtml // the default view
- indexAlternative.phtml // alternative view
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.