Hi all,
Quick question about view helpers - couldn't find the answer having
searched, so here goes. I'm using the standard module based directory tree.
However, I have a number of view helpers that are shared between the
modules, so it doesn't make sense to put them in module/xxx/view/helpers.
Where can I put them, and what steps do I need to take so that they
*autoload* when I call $this->myHelper() from index.phtml?
I tried the following so far:
1. I put all my helpers in /lib/My/View/Helper/ , with appropriate
classnames.
2. In a common parent controller class, I add:
$this->view->addHelperPath(Zend_Registry::get('applicationDir')
. '/lib',
'My_View_Helper');
so that all the controllers have access to them.
3. the /lib/ directory is already in my include path, so that classes can
be autoloaded.
There are no problems finding the right file in the path. However, the
class isn't loaded from the file, because
Zend_View_Controller_Abstract::loadClass() calls class_exists($class,
false). If it called class_exists($class, true), there wouldn't be an
issue. (Why don't we want to autoload here, by the way?)
I'd like to avoid centralised loading of helpers because some of them will
be redundant on most pages. I'd also like to avoid writing include_once or
Zend_Loader all over the place for maintenance and tidiness reasons.
Any help greatly appreciated,
Cheers,
Jamie.
--
View this message in context:
http://www.nabble.com/Lazy-Autoloading-View-Helpers-Shared-Between-Modules-tp15925883s16154p15925883.html
Sent from the Zend Framework mailing list archive at Nabble.com.