php – 如何扩展Zend Navigation Menu View Helper?

我需要更改Zend_View_Helper_Navigation_Menu的输出.我找到了我需要修改的两个功能,我知道如何进行我需要的更改.我不知道的是如何使Navigation对象使用我的视图助手而不是Zend.

代表我的班级额外资讯的代码段:

// file /library/My/View/Helper/Navigation/Menu.PHP
class My_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu
{
    protected function _renderDeepestMenu(Zend_Navigation_Container $container,$ulClass,$indent,$minDepth,$maxDepth)
    {
        // modified code here
    }

    protected function _renderMenu(Zend_Navigation_Container $container,$maxDepth,$onlyActive)
    {
        // modified code here
    }
}

编辑澄清

我想更改< li>元素并删除EOL和缩进.菜单视图脚本没有任何选择,这就是为什么我必须扩展它.

在Bootstrap中初始化导航对象:

$navTable = new Default_Model_Site_DbTable_Navigation();
$view = $this->getResource('view');
$view->navigation(new Zend_Navigation($navTable->getNavigation()));

在我的布局中渲染菜单

echo $this->navigation()->menu();

我通过重命名如下所示的工作,但我不清楚为什么我不能重载/覆盖_Menu类和menu()函数.

>将类名更改为My_View_Helper_Navigation_MyMenu
>将myMenu函数添加到该类(return parent :: menu($container);)
> call echo $this-> navigation() – > myMenu();在布局中

类线框:

// file /library/My/View/Helper/Navigation/MyMenu.PHP
class My_View_Helper_Navigation_MyMenu extends Zend_View_Helper_Navigation_Menu
{
    public function myMenu(Zend_Navigation_Container $container = null)
    {
        return parent::menu($container);
    }

    protected function _renderDeepestMenu(Zend_Navigation_Container $container,$onlyActive)
    {
        // modified code here
    }
}
$view->addHelperPath(
      APPLICATION_ROOT . '/library/MyApp/View/Helper/Navigation','MyApp_View_Helper_'
      );


echo $this->navigation()->myMenu(); // name of your class

从:Getting Zend_Navigation menu to work with jQuery’s Fisheye

编辑

对不起,我没有看到你的解决方案,这正是我发布的.

但是,为什么这不是菜单类的延伸?

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...