2010-06-14 55 views
1

我創造它位於/library/My/View/helpers/SpecialPurpose.php 我的視圖助手類名是My_View_Helper_SpecialPurpose它具有公共職能特殊目的()其返回一些HTML註冊view_helper ZF 1.10.3

我註冊這個路徑在bootstrap.php

$ view = Zend_Layout :: getMvcInstance() - > getView(); $ view-> addBasePath('/ my/view/helpers',「My_View_Helper」);

當我特林特殊目的();?>在一個.phtml

它特羅exeption

Message: Plugin by name 'SpecialPurpose' was not found in the registry; used paths: My_View_Helper_Helper_: /my/view/helpers\helpers/ Zend_View_Helper_: Zend/View/Helper/;D:/WWW/zends/application/modules/default/views\helpers/ 

PS我看了很多帖子的計算器,但任何觀點而不是一個解決方案沒有幫助 如果可能weácan如何做引導和的application.ini ZF版本的任務1.10.3

回答

1

重命名:

My/View/helpers/SpecialPurpose.php

到:

My/View/Helper/SpecialPurpose.php

就是改變helpers文件夾的名稱。 當添加視圖助手路徑添加它想:

$view->addHelperPath('My/View/Helper', 'My_View_Helper');

0

你可以註冊的application.ini太

resources.view.helperPath.My_View_Helper=APPLICATION_PATH "My/Views/Helpers" 

視圖助手,如果你的路徑是APPLICATION_PATH「我/查看/助手」

0

我已經試過etivarianty當我添加

resources.view.helperPath.My_View_Helper=APPLICATION_PATH "My/Views/Helpers" 

我看到這條消息

Message: Plugin by name 'SpecialPurpose' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/;D:/WWW/zends/application/modules/default/views\helpers/ 

Stack trace: 

#0 D:\WebServer\ZendFramework\ZendFramework\library\Zend\View\Abstract.php(1170): Zend_Loader_PluginLoader->load('SpecialPurpose') 
#1 D:\WebServer\ZendFramework\ZendFramework\library\Zend\View\Abstract.php(610): Zend_View_Abstract->_getPlugin('helper', 'specialPurpose') 
#2 D:\WebServer\ZendFramework\ZendFramework\library\Zend\View\Abstract.php(336): Zend_View_Abstract->getHelper('specialPurpose') 
#3 [internal function]: Zend_View_Abstract->__call('specialPurpose', Array) 
#4 D:\WWW\zends\application\modules\default\views\scripts\index\index.phtml(5): Zend_View->specialPurpose() 
#5 D:\WebServer\ZendFramework\ZendFramework\library\Zend\View.php(108): include('D:\WWW\zends\ap...') 
#6 D:\WebServer\ZendFramework\ZendFramework\library\Zend\View\Abstract.php(880): Zend_View->_run('D:/WWW/zends/ap...') 
#7 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Action\Helper\ViewRenderer.php(897): Zend_View_Abstract->render('index/index.pht...') 
#8 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Action\Helper\ViewRenderer.php(918): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL) 
#9 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Action\Helper\ViewRenderer.php(957): Zend_Controller_Action_Helper_ViewRenderer->render() 
#10 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() 
#11 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Action.php(523): Zend_Controller_Action_HelperBroker->notifyPostDispatch() 
#12 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction') 
#13 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) 
#14 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() 
#15 D:\WebServer\ZendFramework\ZendFramework\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
#16 D:\WWW\zends\public\index.php(26): Zend_Application->run() 
#17 {main} 

我改變文件夾名稱相同建議在自舉 和變化

$視圖= Zend_Layout的:: getMvcInstance() - > getView(); $ view-> addBasePath('/ My/View/Helper',「My_View_Helper」);

我有這個消息

Message: Plugin by name 'SpecialPurpose' was not found in the registry; used paths: My_View_Helper_Helper_: My/View/Helper\helpers/ Zend_View_Helper_: Zend/View/Helper/;D:/WWW/zends/application/modules/default/views\helpers/ 

我還沒有這個$視圖 - > addHelperPath屬性(); 此屬性出現時 當我創建$ view = new Zend_View();

可能是什麼原因?

0

試試這個:

$view = Zend_Layout::getMvcInstance()->getView(); $view->addHelperPath(APPLICATION_PATH . 'My/View/Helper', 'My_View_Helper');

(你打電話的Zend_Layout :: startMvc();在你的引導?)最好的 「Zend的方式」 做,這是在引導:: _ initView()

你的助手應該在APPLICATION_PATH/My/View/Helper和名稱應該是class My_View_Helper_SpecialPurpose extends Zend_View_Helper_Abstract

編輯:路徑應該是APPLICATION_PATH . '/../library/My/View/Helper

0

我有這個確切的同樣的問題,對我來說,那是因爲我有

「resources.view [] =」

裏面我的application.ini的。我需要擺脫它。 Zend快速入門教程在其配置中有這個,但是從我可以告訴的是一個錯誤。 您的application.ini中的錯誤可能會級聯錯誤

0

而是調用類Zend_View_Helper_SpecialPurpose。它會工作。