Why do you need to access the view object in the bootstrap?

I'd recommend registering a front controller plugin with Zend_Controller_Front
and than access the view in the preDispatch() method of the plugin, using a
call to Zend_Layout::getMvcInstance()->getView();

The reason is that the view object gets built later in the dispatch cycle than the
layout object (in the default implementation).

Another way of doing it might be to use an action helper which can access the
view object like so:

    $this->getActionController()->view;


On 5/6/2009 11:04, iceangel89 wrote:
how do i get view from the bootstrap file/class?

$view = Zend_Layout::startMvc()->getView();

gives

Fatal error: Uncaught exception 'Zend_Layout_Exception' with message
'setOptions() expects either an array or a Zend_Config object' in
D:\JiewMeng\ZendFramework\library\Zend\Layout.php:234 Stack trace: #0
D:\JiewMeng\ZendFramework\library\Zend\Layout.php(180):
Zend_Layout->setOptions(NULL) #1
D:\JiewMeng\sites\zf-ims\application\modules\lab\Bootstrap.php(5):
Zend_Layout::startMvc() #2
D:\JiewMeng\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(580):
Lab_Bootstrap->_initApp() #3
D:\JiewMeng\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(533):
Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('app') #4
D:\JiewMeng\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstract.php(497):
Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #5
D:\JiewMeng\ZendFramework\library\Zend\Application\Resource\Modules.php(84):
Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() #6
D:\JiewMeng\ZendFramework\library\Zend\Application\Bootstrap\BootstrapAbstra
in D:\JiewMeng\ZendFramework\library\Zend\Layout.php on line 234

--
Ionut G. Stan
I'm under construction  |  http://igstan.blogspot.com/

Reply via email to