我想改变某些zend模块的视图,而不改变它们的代码。我的想法是使用配置(application.ini)改变模块的视图文件夹,而不是其他。
这可能吗?
如何使用模块?如果你不能从外部改变它们,互换性就会下降吗?
我猜你有:
YourModule
- controllers
- views
- alternativeViews
,你想从views
切换到alternativeViews
?你可以使用$view->addScriptPath('/path/to/app/views');
或在application.ini
中添加另一个scriptPatch
。然而,我真的不建议这样做(经常这样做会花费太长时间)。
在我看来,这应该由管制员来决定。因此,您可以保护视图在应用程序中的某个地方使用(也可以是application.ini
),并在控制器中呈现不同的视图:
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