Home > Backend Development > PHP Tutorial > 怎么添加helper路径

怎么添加helper路径

WBOY
Release: 2016-06-13 10:23:03
Original
840 people have browsed it

如何添加helper路径
我在入口文件index.php添加了

$view=new Zend_View();
//Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$view->addHelperPath('Myproject/View/Helper','Myproject_View_Helper');


怎么不起作用?

在library/Myproject/View_Helper/下我新建了一个:
require_once 'Zend/View/Helper/Abstract.php';
class Myproject_View_Helper_RenderMenu extends Zend_View_Helper_Abstract




还是提示:
exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'RenderMenu' was not found in the registry; used paths: Login_View_Helper_: ../application/login/views\helpers/ Zend_View_Helper_: Zend/View/Helper/' in D:\zendstudioworkspace\zendtest\library\Zend\Loader\PluginLoader.php:412 Stack trace: #0 D:\zendstudioworkspace\zendtest\library\Zend\View\Abstract.php(1182): Zend_Loader_PluginLoader->load('RenderMenu') #1 
这个是哪里错了?为什么不会到目录里'Myproject/View/Helper'搜

------解决方案--------------------
最简单的方法,放在/views/helpers/下面,因为这是自动包含的。
或者干脆用Zend_View_Helper_开头,因为这是默认的命名空间。
所以错误的主要原因就是没有指定命名空间。所以如果自定义,需要注册。在配置文件中或者用autoloader完成。
http://blog.csdn.net/mengxiangbaidu/article/details/7479332
http://blog.csdn.net/mengxiangbaidu/article/details/7191723

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template