【问题标题】:Zend_Navigation extending Menu classZend_Navigation 扩展 Menu 类
【发布时间】:2012-10-19 10:12:49
【问题描述】:

问题

我确实需要扩展 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();

【问题讨论】:

  • 我已发布编辑。看看“问题”段落。

标签: zend-framework zend-navigation


【解决方案1】:

在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.';
    }
}

【讨论】:

    猜你喜欢
    • 2011-01-22
    • 1970-01-01
    • 2012-09-08
    • 2012-12-02
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-04
    相关资源
    最近更新 更多