我真的需要扩展Zend_View_Helper_Navigation_Menu以获取其方法的自定义行为。 如果重要的是你知道,我会使用模块。
我已经实施了所有解决方案,它们的组合仍然以失败告终......伙计们,我正在等待任何提示。
编辑:问题是没有任何反应。使用标准助手(工作正常)。
我的 Bootstrap.php 文件:
protected function _initNavigation() {
$this->bootstrap('view');
$view = $this->getResource('view');
$view->addHelperPath('/../library/Application/View/Helper/Navigation', 'Application_View_Helper_');
$view->navigation($this->doGetNavigation());
}
我的Application_View_Helper_Navigation_Menu
课程( ROOT / library / Application / View / Helper / Navigation ):
class Application_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
public function menu(Zend_Navigation_Container $container = null)
{
echo 'Application_View_Helper_Navigation_Menu::menu(...)';
return parent::menu($container);
}
}
我的Zend_Debug::dump($this->getHelperPaths())
来电观看:
array (size=3)
'Zend_View_Helper_' =>
array (size=1)
0 => string 'Zend/View/Helper/' (length=17)
'Application_View_Helper_' =>
array (size=1)
0 => string '/../library/Application/View/Helper/Navigation/' (length=47)
'Fleet_View_Helper_' =>
array (size=1)
0 => string 'C:/repos/statistics/trunk/application/modules/fleet/views\helpers/' (length=70)
我的脚本视图:
echo $this->navigation()->menu();
答案 0 :(得分:0)
在application.ini
中resources.view.helperPath.Test_View_Helper_ = APPLICATION_PATH "/views/helpers"
resources.view.helperPath.Test_View_Helper_Navigation = APPLICATION_PATH "/views/helpers/Navigation"
然后在application / views / helpers / Navigation.php
中class Test_View_Helper_Navigation extends Zend_View_Helper_Navigation
{
public function navigation(Zend_Navigation_Container $container = null)
{
$this->view->getHelper ('Menu');
$this->_helper ['menu'] = new Test_View_Helper_Navigation_Menu();
return parent::navigation($container);
}
}
在application / views / helpers / Navigation / Menu.php
中class Test_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
public function render(Zend_Navigation_Container $container = null)
{
return 'It is I.';
}
}