View Single Post
  #3 (permalink)  
Old 04-30-2008, 01:59 PM
Elemental's Avatar
Elemental Elemental is offline
Senior Member
 
Join Date: Jul 2007
Posts: 119
Default

Davidoff's solution is indeed simple, however it appears as though you're using a conventional modular file structure. If so, then once you have helpers in modules other than default Davidoff's solution will stop working for you.

You could set the helper path per request via an Action Helper and set it based on the requested module as so:
PHP Code:
<?php

require_once('Zend/Controller/Plugin/Abstract.php');

class 
MyApp_Controller_Plugin_ModularHelperPath extends Zend_Controller_Plugin_Abstract
{
    public function 
preDispatch(Zend_Controller_Request_Abstract $request)
    {
        
$moduleName $request->getModuleName();
        
$rootDir Zend_Registry::get('rootDir');
        
set_include_path(get_include_path() .
                         
PATH_SEPARATOR $rootDir '/application/' $moduleName '/views/helpers/');
    }
}
$rootDir = Zend_Registry::get('rootDir') assumes you have set the rootDir in your bootstrap, otherwise you will need to adjust the script to set the paths appropriately.
__________________
Zend Framework Resources: Zend Webinars | Reference Manual | API Docs | Books | FreeNode: #zftalk
Getting Started Tutorials: Getting started with ZF | Getting started with Zend Auth
Reply With Quote