开发者

How to alter Zend Modules from outside their folder?

开发者 https://www.devze.com 2023-03-20 02:23 出处:网络
i\'d like to change the views of c开发者_如何学运维ertain zend modules, without altering their code.

i'd like to change the views of c开发者_如何学运维ertain zend modules, without altering their code. My idea is to change the view folder for a module using the configuration (application.ini) and nothing else.

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? You could use $view->addScriptPath('/path/to/app/views'); or add another scriptPatch in your application.ini. 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:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消