Thanks, that explains why my front controller worked.

After re-reading the documentation a bit, I found I can also register my
script/helper paths using application.ini:

blog.resources.view.scriptPath.scripts = APPLICATION_PATH
"/modules/blog/views/scripts"
blog.resources.view.helperPath.Blog_View_Helper = APPLICATION_PATH
"/modules/blog/views/helpers"

The only drawback to this approach is that it takes a few lines of code to
get the view for this module (which I needed within a site-wide front
controller plugin):

$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$resource = $bootstrap->getPluginResource('modules');
$moduleBootstraps = $resource->getExecutedBootstraps();
$blogBootstrap = $moduleBootstraps['blog'];
$view = $blogBootstrap->getResource('view');

If I just try to access the main view, it will only contain the
script/helper paths for the current module:

$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$view = $bootstrap->getReource('view');
var_dump($view->getScriptPaths()); // only contains current module and
default module paths

My intention is to write a front controller plugin that renders a view
script and places it in a view placeholder. The view script is located
within the blog module, but when I'm in a different module I can't access
the view script. So my current solution load the blog module's view so I can
render the script no matter which module was dispatched.

Thanks again for the quick responses :)

--
Hector


On Tue, Feb 2, 2010 at 9:26 PM, Terre Porter
<[email protected]>wrote:

> I accessed the view object like this in a resource plugin, might work in
> the
> bootstrap also.
>
> $viewRenderer =
> Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
> $viewRenderer->init();
> $this->_view = $viewRenderer->view;
>
> Take a look at
>
> http://www.atirjavid.com/web-development/8-zend-framework-tutorials/4-a-modu
>
> lar-directory-structure-quickstart-module-switcher-front-controller-plugin.h
> tml it is where I got the code.
>
> Or, you could extend you controller file and put in a preDispatch() and set
> the path's there.
>
> class Core_Plugins_Controller_DefaultController extends
> Zend_Controller_Action {
>
> public function preDispatch() {
>        $this->view->addScriptPath(PATH);
>        $this->view->addHelperPath(PATH);
> }
>
> }
>
> class IndexController extends Core_Plugins_Controller_DefaultController {
> ...
> }
>
> Terre
> ________________________________
>
> From: Hector Virgen [mailto:[email protected]]
> Sent: Wednesday, February 03, 2010 12:03 AM
> To: [email protected]
> Subject: Re: [fw-general] Module Resource View Helpers not available to
> Layout
>
>
> Sorry to bring up an old topic but I'm running into an issue trying to
> accomplish this.
>
> I have a module bootstrap that is throwing an exception when I try to
> access
> the "view" resource. Any idea what I might be doing wrong?
>
> http://pastie.org/807111
>
> --
> Hector
>
>
>
> On Sun, Dec 20, 2009 at 1:34 PM, Matthew Weier O'Phinney <[email protected]
> >
> wrote:
>
>
>        -- Ant Cunningham <[email protected]> wrote
>        (on Sunday, 20 December 2009, 01:09 PM -0500):
>
>        > Im currently porting a 1.7 version of an application to 1.9 and
>        > trying to make use of the Module bootstrapping, but i think im
>        > confused on a key point...
>        >
>        > I have a few view helpers that are actually used by the Layout but
>        > are in a "module namespace" (MyModule_View_Helper_*) as opposed to
> a
>        > "global namespace" (My_View_Helper_*). They dont seem to be
>        > available by default for the Layout to use when using the module
>        > autoloader resource.
>        >
>        > I was under the impression the module bootstrapping process front
>        > loaded all the resources for all modules (or in my case all
> enabled
>        > modules). Is this not the case or am i doing it wrong?
>
>
>        Module bootstrapping sets up autoloading, but it doesn't
> automatically
>        add view helper/script/filter paths to the view; that must be done
>        manually currently.
>
>        (Autoloading !== plugin loading, though the latter is affected by
> the
>        former.)
>
>        --
>        Matthew Weier O'Phinney
>        Project Lead            | [email protected]
>        Zend Framework          | http://framework.zend.com/
>
>
>
>
>

Reply via email to