我似乎无法让ZendX_JQuery正常工作。辅助路径不会加载,因此插件不会注册。我已经尝试了所有这些,在引导文件中添加它,在配置中添加等等。 自举:
protected function _initJqueryLoad()
{
$view = new Zend_View();
$view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
//return $view;
}
我的配置:
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.date.timezone = "GMT+2"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
autoloaderNamespaces[] = "JP_"
autoloaderNamespaces[] = "ZendX_"
resources.view.helperPath.JP_View_Helper = "JP/View/Helper"
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper"
autoloaderNamespaces[] = "Sozfo_"
resources.session.save_path = APPLICATION_PATH "/data/sessions"
resources.session.gc_maxlifetime = 18000
resources.session.remember_me_seconds = 18000
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
错误消息:
Message: Plugin by name 'JQuery' was not found in the registry; used paths: JP_View_Helper_: JP/View/Helper/ JP_Controller_Helper_: JP/Controller/Helper/ Sozfo_View_Helper_: Sozfo/View/Helper/ : C:\Zend\Apache2\htdocs\LTSSP\application/helpers/ Zend_View_Helper_: Zend/View/Helper/
Stack trace:
#0 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\View\Abstract.php(1174): Zend_Loader_PluginLoader->load('JQuery')
#1 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\View\Abstract.php(610): Zend_View_Abstract->_getPlugin('helper', 'jQuery')
#2 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\View\Abstract.php(336): Zend_View_Abstract->getHelper('jQuery')
#3 C:\Zend\Apache2\htdocs\LTSSP\application\layouts\baklans.phtml(23): Zend_View_Abstract->__call('jQuery', Array)
#4 C:\Zend\Apache2\htdocs\LTSSP\application\layouts\baklans.phtml(23): Zend_View->jQuery()
#5 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\View.php(108): include('C:\Zend\Apache2...')
#6 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\View\Abstract.php(880): Zend_View->_run('C:\Zend\Apache2...')
#7 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Layout.php(796): Zend_View_Abstract->render('baklans.phtml')
#8 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Layout\Controller\Plugin\Layout.php(143): Zend_Layout->render()
#9 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Controller\Plugin\Broker.php(331): Zend_Layout_Controller_Plugin_Layout->postDispatch(Object(Zend_Controller_Request_Http))
#10 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Controller\Front.php(965): Zend_Controller_Plugin_Broker->postDispatch(Object(Zend_Controller_Request_Http))
#11 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#12 C:\Zend\Apache2\htdocs\LTSSP\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#13 C:\Zend\Apache2\htdocs\LTSSP\public\index.php(51): Zend_Application->run()
答案 0 :(得分:1)
使用的路径:JP_View_Helper_:JP / View / Helper / JP_Controller_Helper_:JP / Controller / Helper / Sozfo_View_Helper_:Sozfo / View / Helper /:C:\ Zend \ Apache2 \ htdocs \ LTSSP \ application / helpers / Zend_View_Helper_:Zend /视图/助手/
基于此,您可能会看到ZendX目录未被扫描。
ZendX
的路径添加到include_path
)在application.ini
:
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper"
在index.php
:
set_include_path(implode(PATH_SEPARATOR, array(
'/home/user/www/library/ZendFramework/1.11.2/library', // Zend dir is here
'/home/user/www/library/ZendFramework/1.11.2/extras/library', // ZendX dir is here
'/home/user/www/library/misc',
get_include_path(),
)));
在视图中:
$this->jQuery()->enable();
答案 1 :(得分:0)
假设您的ZendX在库forlder中,我认为您可以在Bootstrap.php中按如下方式注册JQuery视图助手:
protected function _initJsqueryLoad() {
$this->bootstrap('view');
$view = $this->getResource('view');
$view->addHelperPath(APPLICATION_PATH . '/../library/ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
}
然后不需要配置中的内容。希望它对你有用。
答案 2 :(得分:0)
为我解决这个问题的方法是将帮助路径放在""
而不是''
;
protected function _initJqueryLoad()
{
$view = new Zend_View();
$view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
$view->jQuery()->addStylesheet('/js/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css')
->setLocalPath('/js/jquery/jquery.php')
->setUiLocalPath('/js/jquery-ui-1.7.3.custom.min.js');
$view->jQuery()->enable();
ZendX_JQuery::enableView($view);
return $view;
}
有点小故障。应该发布这个错误。