how to register new helper (custom helper ) in zend framework

跟風遠走 提交于 2020-01-06 08:19:09

问题


i have used $view->addHelperPath and registerHelper what i want is when i go to view scripts files and do this $this->[myhlper method] get the data from my helper class ! i tried to set the path in the application.ini but that dosn't work either,so how to do it ?


回答1:


in your Bootstrap, add this method :

protected function _initView()
{
        $view = $this->bootstrap('layout')->getResource('layout')->getView();
        $view->addHelperPath('Your/Custom/Path/', 'Your_Custom_Path');

        $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
        $viewRenderer->setView($view);

        Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}



回答2:


You can add this addHelperPath call in bootstrap, like me



来源:https://stackoverflow.com/questions/6358483/how-to-register-new-helper-custom-helper-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!