View Single Post
  #4 (permalink)  
Old 04-30-2008, 08:02 PM
freenity freenity is offline
Junior Member
 
Join Date: Apr 2008
Posts: 8
Default

Quote:
Originally Posted by Elemental View Post
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.
Thanks for the reply guys.
I will try the Davidoffs solution, I was hoping was something that would work by putting it in the bootstrap file once, seems like this should work.
Reply With Quote