-- Mauricio Cuenca <[EMAIL PROTECTED]> wrote
(on Monday, 18 February 2008, 07:09 AM -0800):
> Is it possible to have a common directory of helpers for the whole
> application, not specific ones for each module???

Of course. Simply tell the view object where to find them, and what
their class prefix is. You can do this in your bootstrap, or from a
plugin. Most likely, you'll want to use code such as the following:

    $view = new Zend_View();
    $view->addHelperPath('path/to/My/View/Helper', 'My_View_Helper');
    
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView($view);

> My application got bigger and I moved some controller to its own module and
> now the usual path (application/views/helpers) is not recognized.
> 
> 
> 
> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- ashish.sharma <[EMAIL PROTECTED]> wrote
> > (on Monday, 10 December 2007, 03:34 AM -0800):
> >> i have a query regarding helpers,i have helpers in my default module
> >> helpers
> >> folder i:e(in application/views/helpers/generateKey.php) now i have
> >> created
> >> new module and i want to use that helper in this module.how can i do this
> >> ,plz help me as its very urgent.
> > 
> > Short answer:
> > 
> >     // within your action controller:
> >     $conDirs =
> > Zend_Controller_Front::getInstance()->getControllerDirectory();
> >     $defDir  = dirname($conDirs['default']) . '/views/helpers';
> >     $this->view->addHelperPath($defDir);
> > 
> > Long answer:
> > 
> > You grab the controller directory associated with the module you wish to
> > use, determine the views directory associated with it, and add its
> > helpers subdirectory as a helper path on the view object.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to