2011-11-18 59 views
1

我的文件看起來像這樣全球幫手:爲Zend的模塊結構

/Zend 
    /Application 
    /Configs 
    /Modules 
     /home 
      /controllers 
      /views 
     /login 
      /controllerS    
      /forms 
      /library 
      /login 
      /models 
      /plugins 
      /views 

我想創造出可以由所有模塊使用的幫手。有點「全球幫手」。有沒有一個標準的方法來完成這個?

回答

1

什麼樣的幫手?視圖?或者像行動助手一樣?如果它只是一個實用程序樣式類(不附加到MVC的特定部分),只需將它放入/library/NAMESPACE即可。

然後只需將該名稱空間添加到application.ini中的自動加載器。

autoloadernamespaces[] = NAMESPACE 

然後你可以

$helper = new NAMESPACE_Helper(); 
+0

'\t \t $視圖=新的Zend_View(); \t \t $ mypath = $ this-> view-> getHelperPaths(); \t \t $ view-> addHelperPath($ mypath ['Login_View_Helper_'],'RenderIfExists'); $ this-> renderIfExists('login.phtml'); ' – Proto

+0

'\t \t $ view = new Zend_View(); \t \t $ mypath = $ this-> view-> getHelperPaths(); \t \t $ view-> addHelperPath($ mypath ['Login_View_Helper _'] [0],'RenderIfExists'); $ this-> renderIfExists('login.phtml'); '這給了我錯誤:'消息:方法「renderIfExists」不存在,並且沒有被封存在__call()中。我的助手是正確的。我用echo $ mypath ['Login_View_Helper _'] [0]'來檢查它 – Proto