开发者

Unable to initialize Jquery(Zendx) and View helpers in Bootstrap.php(ZF: 1.10.8)

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->__cal开发者_如何学Gol('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.


You could add the Setup for your View Helpers to your application.ini (instead of your initView Method):

resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper"
pluginPaths.ZendX_Application_Resource = "ZendX/Application/Resource"

Or if you need your custom bootstrap try to use an "existing view object":

protected function _initView()
{       
   $this->bootstrap('view'); 
   $view = $this->getResource('view');
   $view->doctype('XHTML1_STRICT');

   // better use " instead of ' , seems to be an bug
   $view->addHelperPath("Vapps/View/Helper/",'Vapps_View_Helper');
   $view->addHelperPath("ZendX/JQuery/View/Helper",'ZendX_JQuery_View_Helper');
   return $view;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜