使用时出现问题
resources.view.helperPath.App_View_Helper = APPLICATION_PATH "/../library/App/views/helpers"
我无法访问布局中的视图助手,甚至模块中的本地助手。(在注册表中找不到名为“LoggedInAs”的插件)但仍在视图模板文件中工作。
我将此代码“echo Zend_Debug::dump($this)”放在布局文件的末尾,并且有一部分输出。
["_prefixToPaths:protected"] => array(3) {
["Zend_View_Helper_"] => array(2) {
[0] => string(17) "Zend/View/Helper/"
[1] => string(16) "./views\helpers/"
}
["ZendX_JQuery_View_Helper_"] => array(1) {
[0] => string(25) "ZendX/JQuery/View/Helper/"
}
["Zend_View_Helper_Navigation_"] => array(1) {
[0] => string(28) "Zend/View/Helper/Navigation/"
}
}
但是在引导文件中使用这些代码时没有问题。
//Initialize and/or retrieve a ViewRenderer object on demand via the helper broker
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->initView();
//add the global helper directory path
$viewRenderer->view->addHelperPath(APPLICATION_PATH.'/../library/App/views/helpers', 'App_View_Helper');
输出如下:
["_prefixToPaths:protected"] => array(4) {
["Zend_View_Helper_"] => array(3) {
[0] => string(17) "Zend/View/Helper/"
[1] => string(16) "./views\helpers/"
[2] => string(86) "D:/zf/application/modules/default/views\helpers/"
}
["App_View_Helper_"] => array(1) {
[0] => string(85) "D:\zf\application/../library/App/views/helpers/"
}
["ZendX_JQuery_View_Helper_"] => array(1) {
[0] => string(25) "ZendX/JQuery/View/Helper/"
}
["Zend_View_Helper_Navigation_"] => array(1) {
[0] => string(28) "Zend/View/Helper/Navigation/"
}
}