开发者

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

开发者 https://www.devze.com 2023-03-13 08:10 出处:网络
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

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 ?


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);
}


You can add this addHelperPath call in bootstrap, like me

0

精彩评论

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

关注公众号