【问题标题】:Magento Add custom links to nav menuMagento 将自定义链接添加到导航菜单
【发布时间】:2014-02-04 08:58:55
【问题描述】:

我需要知道在 magento 导航菜单中添加菜单的最简单方法。 是否有 FREE 扩展程序可以提供将自定义链接添加到导航菜单的功能无需从 Magento 进行任何重写

我已经进行了研究,但没有成功。谁能帮帮我?

【问题讨论】:

    标签: php html magento e-commerce shopping-cart


    【解决方案1】:

    你试过 MegaMenu master 吗?是一个免费的扩展,可以在 GitHub 上找到。

    【讨论】:

    • 这是一个很好的扩展,但不幸的是他们不提供 magento 管理设置。因此,您需要编辑代码以添加新链接。还是谢谢你
    【解决方案2】:

    如果您正在使用 Magento ce 1.7+,您可以使用事件page_block_html_topmenu_gethtml_before
    在 1.7+ 版本中,顶部菜单被视为一个容器,您可以在其中放置所需的任何链接。
    这是一个小例子。您的观察者可能如下所示:

    class [Namespace]_[Module]_Model_Observer {
        public function addItemsToTopmenuItems($observer) {
            $menu = $observer->getMenu();
            $tree = $menu->getTree();
            $action = Mage::app()->getFrontController()->getAction()->getFullActionName();
    
            $nodeId = 'some-node-id';
            $data = array(
                'name' => Mage::helper('[module]')->__('Title goes here'),
                'id' => $nodeId,
                'url' => Mage::getUrl('module/controller/action'),
                'is_active' => ($action == 'module_controller_action')
            );
            $node = new Varien_Data_Tree_Node($data, 'id', $tree, $menu);
            $menu->addChild($node);
            return $this;
        }
    }
    

    以及config.xml中的事件声明

    <frontend>
        <events>
            <page_block_html_topmenu_gethtml_before>
                <observers>
                    <[module]>
                        <class>[module]/observer</class>
                        <method>addItemsToTopmenuItems</method>
                    </[module]>
                </observers>
            </page_block_html_topmenu_gethtml_before>
        </events>
    </frontend>
    

    这将在类别之后添加一个项目。
    在菜单的开头或中间添加项目check this

    注意:当然这是一个例子。您可以使您的模块支持通过配置面板或其他任何您可以做的事情添加链接。

    【讨论】:

      猜你喜欢
      • 2018-10-05
      • 2017-03-11
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2012-09-05
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多