无法初始化 Jquery(Zendx) 和 Bootstrap.php 中的视图助手(ZF: 1.10.8)
我无法在 Bootstrap.php(ZF: 1.10.8) 中初始化 Jquery(Zendx) 和 View 帮助程序,
但我能够在每个控制器的 init() 方法中初始化相同的内容。
//我的 Bootstrap.php
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->addHelperPath('Vapps/View/Helper/','Vapps_View_Helper');
$view->addHelperPath('ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
return $view;
}
}
以下是我运行简单控制器时的错误,
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'JQuery' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:/opt/lampp/htdocs/schooldir/application/views/helpers/' in /opt/lampp/htdocs/schooldir/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(1174): Zend_Loader_PluginLoader->load('JQuery') #1 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(610): Zend_View_Abstract->_getPlugin('helper', 'jQuery') #2 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(336): Zend_View_Abstract->getHelper('jQuery') #3 [internal function]: Zend_View_Abstract->__call('jQuery', Array) #4 /opt/lampp/htdocs/schooldir/application/layouts/scripts/layout.phtml(29): Zend_View->jQuery() #5 /opt/lampp/htdocs/schooldir/library/Zend/View.php(108): include('/opt/lampp/htdo...') #6 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(880): Zend_View->_run('/opt/lampp/htdo...') #7 /opt/lamp in /opt/lampp/htdocs/schooldir/library/Zend/Loader/PluginLoader.php on line 412
如果我在控制器中使用以下 init() ,则不会收到相同的错误。
class ViewhelperexampleController extends Zend_Controller_Action
{
public function init() {
$this->view->addHelperPath('ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
$this->view->addHelperPath('Vapps/View/Helper/','Vapps_View_Helper');
}
public function indexAction()
{
}
}
请帮助我。提前致谢。
Im unable to initialize Jquery(Zendx) and View helpers in Bootstrap.php(ZF: 1.10.8)
But Im able to initialize the same in every controller's init() method.
//My Bootstrap.php
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->addHelperPath('Vapps/View/Helper/','Vapps_View_Helper');
$view->addHelperPath('ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
return $view;
}
}
Following is the error when i run a simple controller,
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'JQuery' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:/opt/lampp/htdocs/schooldir/application/views/helpers/' in /opt/lampp/htdocs/schooldir/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(1174): Zend_Loader_PluginLoader->load('JQuery') #1 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(610): Zend_View_Abstract->_getPlugin('helper', 'jQuery') #2 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(336): Zend_View_Abstract->getHelper('jQuery') #3 [internal function]: Zend_View_Abstract->__call('jQuery', Array) #4 /opt/lampp/htdocs/schooldir/application/layouts/scripts/layout.phtml(29): Zend_View->jQuery() #5 /opt/lampp/htdocs/schooldir/library/Zend/View.php(108): include('/opt/lampp/htdo...') #6 /opt/lampp/htdocs/schooldir/library/Zend/View/Abstract.php(880): Zend_View->_run('/opt/lampp/htdo...') #7 /opt/lamp in /opt/lampp/htdocs/schooldir/library/Zend/Loader/PluginLoader.php on line 412
I dont get the same error, if I use the following init() in my controller.
class ViewhelperexampleController extends Zend_Controller_Action
{
public function init() {
$this->view->addHelperPath('ZendX/JQuery/View/Helper','ZendX_JQuery_View_Helper');
$this->view->addHelperPath('Vapps/View/Helper/','Vapps_View_Helper');
}
public function indexAction()
{
}
}
Kindly help me out. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将视图助手的设置添加到 application.ini (而不是 initView 方法):
或者如果您需要自定义引导程序,请尝试使用“现有视图对象”:
You could add the Setup for your View Helpers to your application.ini (instead of your initView Method):
Or if you need your custom bootstrap try to use an "existing view object":