Reputation: 1262
I'm developing a modular application with Zend Framework and I find that I use a lot of view helpers that are common across all my modules, I would like to have the following structure work, where I have a central location of view helpers to use in any module plus each module having its own view helpers, is this possible?
APPLICATION_PATH
/modules/module1/views/helpers
/modules/module2/views/helpers
/modules/module3/views/helpers
/views/helpers <-- central location for all modules
Upvotes: 0
Views: 61
Reputation: 1262
Thank you joellord for your help, based on the information given by joellord I was able to load view helpers from a central location plus the view helpers located in each of my modules. I added the following to my main application bootstrap file:
public function _initView(){
$view = new Zend_View($this->getOptions());
$view->setEncoding('UTF-8');
$view->addHelperPath(APPLICATION_PATH.'/helpers/', 'Application_Helpers_');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
return $view;
}
Upvotes: 1
Reputation: 2173
In my Bootstrap, I have the following function:
protected function _initView() {
$view->addHelperPath(APPLICATION_PATH."/../library/Myapp/View/Helper/", 'Myapp_View_Helper_');
}
That helps me achieve what I think you want. My general helpers are all located in /library/Myapp/View/Helper
Upvotes: 0