我创建了我的视图助手,它位于/library/My/View/helpers/SpecialPurpose.php中 类名是My_View_Helper_SpecialPurpose它有公共函数specialPurpose()它返回一些HTML
我在bootstrap.php中注册了这个路径
$ view = Zend_Layout :: getMvcInstance() - > getView(); $视图 - > addBasePath( '/我/视图/助手', “My_View_Helper”);
当我使用specialPurpose();?>在任何视图.phtml
它提出了解释
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/
P.S我在stackoverflow中阅读了很多帖子,但没有一个解决方案没有帮助 如果有可能我们可以用bootstrap和application.ini来完成这项任务 zf版本1.10.3
答案 0 :(得分:1)
重命名:
My/View/helpers/SpecialPurpose.php
为:
My/View/Helper/SpecialPurpose.php
即更改helpers
文件夹的名称。
添加视图助手路径时,请添加如下:
$view->addHelperPath('My/View/Helper', 'My_View_Helper');
答案 1 :(得分:0)
你也可以在application.ini中注册视图助手
resources.view.helperPath.My_View_Helper=APPLICATION_PATH "My/Views/Helpers"
如果您的路径是APPLICATION_PATH“我的/观看/助手”
答案 2 :(得分:0)
当我添加
时,我尝试了etivariantyresources.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}
我更改了同样建议的文件夹名称 并改变引导程序
$ view = Zend_Layout :: getMvcInstance() - > getView(); $视图 - > addBasePath( '/我/视图/助手', “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/
此$ view中没有属性 - > addHelperPath(); 此属性出现 当我创建$ view = new Zend_View();
可能是什么原因?
答案 3 :(得分:0)
试试这个:
$view = Zend_Layout::getMvcInstance()->getView();
$view->addHelperPath(APPLICATION_PATH . 'My/View/Helper', 'My_View_Helper');
(你有没有在你的Bootstrap中调用Zend_Layout :: startMvc();)最好的“Zend方式”是在Bootstrap :: _ initView()
您的助手应位于APPLICATION_PATH/My/View/Helper
,名称应为class My_View_Helper_SpecialPurpose extends Zend_View_Helper_Abstract
编辑:路径应为APPLICATION_PATH . '/../library/My/View/Helper
答案 4 :(得分:0)
我有同样的问题,对我来说,那是因为我有
“resources.view [] =”
在我的application.ini中。我需要摆脱它。 Zend快速入门教程在其配置中有这个,但是从我能说的是错误。 application.ini中的错误可能是级联错误
答案 5 :(得分:0)
改为调用类Zend_View_Helper_SpecialPurpose。它会工作。