• <small id='z04j6'></small><noframes id='z04j6'>

  • <i id='z04j6'><tr id='z04j6'><dt id='z04j6'><q id='z04j6'><span id='z04j6'><b id='z04j6'><form id='z04j6'><ins id='z04j6'></ins><ul id='z04j6'></ul><sub id='z04j6'></sub></form><legend id='z04j6'></legend><bdo id='z04j6'><pre id='z04j6'><center id='z04j6'></center></pre></bdo></b><th id='z04j6'></th></span></q></dt></tr></i><div id='z04j6'><tfoot id='z04j6'></tfoot><dl id='z04j6'><fieldset id='z04j6'></fieldset></dl></div>
    <legend id='z04j6'><style id='z04j6'><dir id='z04j6'><q id='z04j6'></q></dir></style></legend>
      <bdo id='z04j6'></bdo><ul id='z04j6'></ul>

    <tfoot id='z04j6'></tfoot>

        如何扩展 Zend Navigation Menu View Helper?

        时间:2023-10-03

          <small id='VJL6D'></small><noframes id='VJL6D'>

              <legend id='VJL6D'><style id='VJL6D'><dir id='VJL6D'><q id='VJL6D'></q></dir></style></legend>
                <tbody id='VJL6D'></tbody>

            • <tfoot id='VJL6D'></tfoot>
                <bdo id='VJL6D'></bdo><ul id='VJL6D'></ul>
              • <i id='VJL6D'><tr id='VJL6D'><dt id='VJL6D'><q id='VJL6D'><span id='VJL6D'><b id='VJL6D'><form id='VJL6D'><ins id='VJL6D'></ins><ul id='VJL6D'></ul><sub id='VJL6D'></sub></form><legend id='VJL6D'></legend><bdo id='VJL6D'><pre id='VJL6D'><center id='VJL6D'></center></pre></bdo></b><th id='VJL6D'></th></span></q></dt></tr></i><div id='VJL6D'><tfoot id='VJL6D'></tfoot><dl id='VJL6D'><fieldset id='VJL6D'></fieldset></dl></div>

                  本文介绍了如何扩展 Zend Navigation Menu View Helper?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

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

                  I need to change the output of Zend_View_Helper_Navigation_Menu. I've found the two functions that I'll need to modify, and I know how to make the changes I need. What I don't know is how to make the Navigation object use my view helper instead of the Zend one.

                  代表我的类扩展的代码片段:

                  Code snippet representing my class extension:

                  // 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,
                                                     $ulClass,
                                                     $indent,
                                                     $minDepth,
                                                     $maxDepth,
                                                     $onlyActive)
                      {
                          // modified code here
                      }
                  }
                  

                  <小时>

                  编辑以澄清

                  我想更改

                1. 元素的类并删除 EOL 和缩进.菜单视图脚本没有选项可以做到这一点,这就是我必须扩展它的原因.

                  I want to change the class of the <li> elements and remove the EOL and indentation. There are no options to do that with the menu view script, which is why I'll have to extend it.

                  在我的 Bootstrap 中初始化导航对象:

                  Initializing the navigation object in my Bootstrap:

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

                  在我的布局中渲染菜单:

                  Rendering the menu in my layout:

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

                  <小时>

                  解决方案

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

                  I got it working by renaming things as follows, but I am not clear on why I can't overload/overwrite the _Menu class and menu() function.

                  1. 将类名更改为My_View_Helper_Navigation_MyMenu
                  2. 在类中添加myMenu函数(return parent::menu($container);)
                  3. 在布局中调用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,
                                                            $ulClass,
                                                            $indent,
                                                            $minDepth,
                                                            $maxDepth)
                      {
                          // modified code here
                      }
                  
                      protected function _renderMenu(Zend_Navigation_Container $container,
                                                     $ulClass,
                                                     $indent,
                                                     $minDepth,
                                                     $maxDepth,
                                                     $onlyActive)
                      {
                          // modified code here
                      }
                  }
                  

                  推荐答案

                     $view->addHelperPath(
                        APPLICATION_ROOT . '/library/MyApp/View/Helper/Navigation',
                        'MyApp_View_Helper_'
                        );
                  
                  
                  echo $this->navigation()->myMenu(); // name of your class
                  

                  来自:让 Zend_Navigation 菜单工作使用 jQuery 的鱼眼

                  编辑

                  抱歉,我没有看到您的解决方案,这正是我发布的内容.

                  Sorry I've not seen your solution, it is exactly what I've posted.

                  但为什么这不是菜单类的真正扩展?

                  But why this is not a trully extension of menu class?

                  这篇关于如何扩展 Zend Navigation Menu View Helper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                2. 上一篇:实用 Zend_ACL + Zend_Auth 实现和最佳实践 下一篇:Zend框架中重定向和转发有什么区别

                  相关文章

                  最新文章

                      <bdo id='caIux'></bdo><ul id='caIux'></ul>

                    1. <small id='caIux'></small><noframes id='caIux'>

                    2. <legend id='caIux'><style id='caIux'><dir id='caIux'><q id='caIux'></q></dir></style></legend>
                    3. <i id='caIux'><tr id='caIux'><dt id='caIux'><q id='caIux'><span id='caIux'><b id='caIux'><form id='caIux'><ins id='caIux'></ins><ul id='caIux'></ul><sub id='caIux'></sub></form><legend id='caIux'></legend><bdo id='caIux'><pre id='caIux'><center id='caIux'></center></pre></bdo></b><th id='caIux'></th></span></q></dt></tr></i><div id='caIux'><tfoot id='caIux'></tfoot><dl id='caIux'><fieldset id='caIux'></fieldset></dl></div>
                      <tfoot id='caIux'></tfoot>