本文介绍了我如何在zend中添加视图助手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 我将以下代码放在application.ini中:
- I placed in application.ini this code:
$ view-> addHelperPath('MyView/Helpers',"library_MyView_Helpers");
$ viewRenderer = Zend_Controller_Action_HelperBroker :: getStaticHelper('ViewRenderer');$ viewRenderer-> setView($ view);
$view->addHelperPath('MyView/Helpers', "library_MyView_Helpers");
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');$viewRenderer->setView($view);
推荐答案
根据ZF编码应用程序结构,正确的版本应为:
According to ZF coding application structure, correct version would be:
在application.ini中:
In application.ini:
resources.view.helperPath.Your_View_Helper = "Your/View/Helper"
然后是助手:(不确定为什么需要另一个抽象类):
Then the helpers: (not sure why do you need another abstract class):
// library/Your/View/Helper/TabEntry/Abstract.php
class Your_View_Helper_TabEntry_Abstract extends Zend_View_Helper_Abstract {
public function tabEntry($param1, $param2) {} // note the lower case here
}
// library/Your/View/Helper/TabEntries.php
class Your_View_Helper_TabEntries extends Your_View_Helper_TabEntry_Abstract {
public function tabEntries($param1, $param2) {...} // note the lower case
}
在视图中:
$this->tabEntries();
重要提示:call_user_func
和Linux文件系统区分大小写.
Important: call_user_func
and Linux filesystem are case sensitive.
这篇关于我如何在zend中添加视图助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!