简体   繁体   中英

How to alter Zend Modules from outside their folder?

i'd like to change the views of certain 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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