0

我想改變某些Zend的模塊的視圖,而無需改變他們的代碼。 我的想法是改變視圖文件夾使用配置(的application.ini),並沒有其他的模塊。如何從他們的文件夾外改變Zend模塊?

這可能嗎?

否則怎麼使用模塊?如果你不能從外面改變它們,那麼互換性的降低是否值得呢?

回答

1

我猜你:

YourModule 
- controllers 
- views 
- alternativeViews 

,並要切換從viewsalternativeViews?你可以使用$view->addScriptPath('/path/to/app/views');或添加其他scriptPatchapplication.ini。但是,我真的很缺乏(這樣做往往會花費太長時間)。

在我看來,這是控制器的工作來決定。因此,你安全地在你的應用程序當中使用的視圖(可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 
+0

嗯,這不是正是我想要的,但它仍然回答我的問題。謝謝Fge! –

相關問題