Reputation: 6085
I have $view variables in two function in bootstrap file they don't work at the same time unless i comment out one of them, i need to use both function please help
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
// $view = $layout->getView();
// $navigation = new Zend_Navigation($this->getOption('navigation'));
// $view->navigation($navigation);
}
protected function _initjQuery(){
$view = new Zend_View();
$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
Upvotes: 1
Views: 546
Reputation: 33148
In one function you're using the View object from the layout resource, and in the other you're creating a new View object. If you change your second function to work like the first you don't need to create a new View or inject it into the view renderer.
I'd suggest changing your code to this:
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$navigation = new Zend_Navigation($this->getOption('navigation'));
$view->navigation($navigation);
}
protected function _initjQuery()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
}
Upvotes: 2