如何在zend框架中注册新的助手(custom helper) [英] how to register new helper (custom helper ) in zend framework
本文介绍了如何在zend框架中注册新的助手(custom helper)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用$ view-> addHelperPath和registerHelper我想要的是当我去查看脚本文件并执行此$ this-> [myhlper方法]时从我的帮助器类中获取数据!我试图在application.ini中设置路径,但是那也不行,所以怎么做?
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 ?
推荐答案
在您的Bootstrap中,添加以下方法:
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);
}
这篇关于如何在zend框架中注册新的助手(custom helper)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文