视图脚本无法识别 zend 框架中的视图助手
我的问题是,当我从视图脚本调用视图助手时,它无法被调用 虽然我通过这一行正确添加了配置文件的所有信息路径:
resources.view.helperPath.ZF_View_Helper_="ZF/View/Helper/"
我还在引导文件中注册了帮助程序
function _initViewHelpers(){
$view = new Zend_View();
$view->addHelperPath('ZF/View/Helper','ZF_View_Helper');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
,但徒劳地它仍然打印出此错误消息:
Application error
Exception information:
Message: Plugin by name 'OutputHelper' was not found in the registry; used paths:
Zend_View_Helper_: Zend/View/Helper/
它不包括预期的自定义视图帮助程序路径;
视图助手的路径是:library/ZF/View/Helper/OutputHelper.php
my problem is fairly when I call a view helper from view script it can't be called
although I added properly all information path to the config file via this line:
resources.view.helperPath.ZF_View_Helper_="ZF/View/Helper/"
also I registered the helper in bootstrap file
function _initViewHelpers(){
$view = new Zend_View();
$view->addHelperPath('ZF/View/Helper','ZF_View_Helper');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
but in vain it still printing out this error message:
Application error
Exception information:
Message: Plugin by name 'OutputHelper' was not found in the registry; used paths:
Zend_View_Helper_: Zend/View/Helper/
it doesn't include the custom view helper path as expected ;
the path of the view helper is: library/ZF/View/Helper/OutputHelper.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能这样做吗:
在视图脚本中,
我认为你的视图实例在某个时刻被替换。
模块的引导程序可能有查看资源吗?
或者也可能是其他明显的错误。如此明显,所以您永远不会想到
删除 _initViewHelpers 方法。 Zend_Application_Resource_View 工作得很好。
如果您使用此方法,请正确使用它,例如:
can you do this:
in view script
I think your view instance are replaced at some point.
May be module's bootstrap have view resource?
Or it can be other obvious mistake. So obvious so you'll never think of it
btw remove that _initViewHelpers method. Zend_Application_Resource_View work just fine for that.
And if you use this method, use it correctly, eg: