I'm writing an application in 1.10.7 using Zend_Application. Due to
front-end design considerations, I have to change the location of the view
scripts (and only the view scripts). I have a few issues, though...

==============================
#1: Repetition
==============================

It appears that this needs to be done in each module's bootstrap. So, I do
this in the "default" bootstrap file:

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initModifiedView()
    {
        $this->bootstrap( 'View' );
        $view = $this->getResource( 'View' );
        $view->setScriptPath( realpath( APPLICATION_PATH . '/../custom/path'
) );
    }
}

?>

But I also have to do this in the "Module" bootstrap file, adding the
module's name to the path:

<?php

class Module_Bootstrap extends Zend_Application_Module_Bootstrap
{
    protected function _initModifiedView()
    {
        $this->bootstrap( 'View' );
        $view = $this->getResource( 'View' );
        $view->setScriptPath( realpath( APPLICATION_PATH .
'/../custom/path/module' ) );
    }
}

?>

Is there a better way to do this globally and still have modules looking in
the correct directory? A controller plugin, perhaps? (I'm hoping a better
solution to this issue will make the next two disappear.)

==============================
#2: Default Paths Still Present
==============================

Zend_View::setScriptPath() overrides the default path(s). Unfortunately,
that doesn't appear to be the case here. Dumping the view object (inside of
a view script) reveals that the default path is still being checked.

["script"] => array(2) {
    [0] => string(86) "[base]/application/views/scripts/"
    [1] => string(69) "[base]/custom/path/"
}

["script"] => array(2) {
    [0] => string(86) "[base]/application/modules/module/views/scripts/"
    [1] => string(69) "[base]/custom/path/module/"
}

While this makes sense to me—these paths must be generated some time after
bootstrapping and then added to the view resource object—it's not very
optimal.

I'd like to completely override the default view script path. Any
suggestions?

==============================
#3: Error Handling in Modules
==============================

If ErrorController::errorAction() needs to be invoked by an exception in a
module, it seems to check the "default" default view script path, the
"Module" default view script path, and the "Module" custom view script path,
but *not* the "default" custom view script path:

    [base]/application/views/scripts/
    [base]/application/modules/module/views/scripts/
    [base]/custom/path/module/

Consequently, with my setup, the view script for the error controller/action
can't be found, resulting in a fatal error.

Any help with these would be much appreciated.


Thanks,
Ryan

Reply via email to