0

问题

我真的需要扩展 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();
4

1 回答 1

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.';
    }
}
于 2012-10-23T20:03:44.590 回答