繁体   English   中英

如何从文件夹外部更改 Zend 模块?

[英]How to alter Zend Modules from outside their folder?

我想更改某些 zend 模块的视图,而不更改它们的代码。 我的想法是使用配置(application.ini)更改模块的视图文件夹,仅此而已。

那可能吗?

如何使用模块? 如果你不能从外部改变它们,那么互换性就会下降吗?

我猜你有:

YourModule
- controllers
- views
- alternativeViews

并且您想从views切换到alternativeViews视图? 你可以使用$view->addScriptPath('/path/to/app/views'); 或在您的application.ini中添加另一个scriptPatch 但是,我真的不建议这样做(经常这样做会花费太长时间)。

在我看来,这是控制器的工作来决定。 因此,您可以保护在应用程序中使用的视图(也可以是application.ini )并在 controller 中呈现不同的视图:

public function indexAction()
{
    // decide which view to render, save name of view in $viewName
    $this->render($viewName);
}

使用这个文件结构:

YourModule
- controllers
- views
    - scripts
        - yourController
            - index.phtml              // the default view
            - indexAlternative.phtml   // alternative view

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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