Zend Framework - 共享视图脚本路径(全局部分)

How is it possible to set up a shared view script path for partials to create global partials within the Zend Framework?

We know that you can call partials between modules

e.g  -  echo        $this->partial('partial_title','module_name');

but we need to set up a partial folder in the root ( i.e below modules) so that it can be accessble by all views.

It has been suggested to set up a shared view script path, how is this done?

Zend_View has a method called addScriptPath, so in a Zend_Controller_Action subclass you could do something like:

$this->view->addScriptPath("/path/to/your/view/scripts/");

Now when you call render or partial or partialLoop, that path will be included in the paths.

I have got a solution. We can do this by specifying the location of the view:

Calling partial as above form Module/Controller page

Method 1:

$this->view->addScriptPath("/ModuleConatinerDirectory/ModuleName/view/scripts/");

Then load using:

$message = $this->view->partial('templates/default.phtml','contact',array('var'=> 'var');

For the second option, please read the following:

http://framework.zend.com/issues/browse/ZF-6201

Now my doubt is, whether it is possible on setting it directly on Bootstrap file for all my Modules ? If so, how can I set this for two modules Module1 and Module2

$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper( 'viewRenderer' ); $viewRenderer->setViewBasePathSpec( '/some/absolute/path/to/templates/:module/' );