【问题标题】:How to add menu in magento admin panel?如何在 magento 管理面板中添加菜单?
【发布时间】:2013-08-26 13:02:03
【问题描述】:

我正在寻找有关如何执行以下操作的建议或信息。我想在 magento 管理面板中再添加一个菜单。我正在尝试很多方法但没有工作。我如何在管理面板中添加额外的一个菜单。请指教...

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    如果这是您的自定义模块,您需要在 etc/config.xml 添加以下内容:

    <adminhtml>
      <menu>
          <report>
            <children>
              <module name>
                <title>Title to show in the menu bar</title>
                <sort_order>0</sort_order>
                <action>Modules controller action</action>
              </module name>
            </children>
          </report>
        </menu>
     </adminhtml>
    

    上面的示例将在报告选项卡中添加一个新项目,并在控制器中触发一个动作来做某事。希望这会有所帮助。

    【讨论】:

    • 在 1.9 中仍然适用
    【解决方案2】:

    您可以使用自定义模块添加菜单 下面的教程对我有很大帮助 请点击here

    【讨论】:

      【解决方案3】:

      我正在创建一个模块。

      info - 公司名称文件夹

      ExtendedMenu - 模块名称

      我正在模块文件夹中创建 2 个新文件夹。

      等和阻止

      etc 文件夹我正在创建 config.xml 文件

      <?xml version="1.0" encoding="UTF-8"?>
      <config>
          <modules>
              <Info_ExtendedMenu>
                  <version>0.1.0</version>
              </Info_ExtendedMenu>
          </modules>
          <global>
              <blocks>
                  <configurable>
                      <class>Info_Configurable_Block</class>
                  </configurable>
                  <adminhtml>
                      <rewrite>
                          <page_menu>Info_ExtendedMenu_Block_Adminhtml_Menu</page_menu>
                      </rewrite>
                  </adminhtml>
              </blocks>
              <blocks>
                  <configurable>
                      <class>Inchoo_Configurable_Block</class>
                  </configurable>
              </blocks>
          </global>
      </config>
      

      块 -- Adminhtml - Menu.php

      <?php
      class Info_ExtendedMenu_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Page_Menu
      {
          public function getMenuArray()
          {
              //Load standard menu
              $parentArr = parent::getMenuArray();
      
              //Prepare "View Sites" menu
              $parentArr['view_sites'] = array(
                  'label' => 'Web2Print',
                  'active'=>false ,
                  'sort_order'=>0,
                  'click' => 'return false;',
                  'url'=>'#',
                  'level'=>0,
                  'last'=> true,
                  'children' => array()
              );
      
              $app = Mage::app();
      
              $j = 0;
      
              $allWebsites = $app->getWebsites();
              $totalWebsiteCount = count($allWebsites) - 1;
      
              foreach ($allWebsites as $_eachWebsiteId => $websiteVal){
                  $_storeName = $app->getWebsite($_eachWebsiteId)->getName();
                  $baseUrl = $app->getStore($_eachStoreId)->getUrl();
                  $_websiteUrl = array(
                                  'label' => 'View Admin',
                                  'active' => false ,
                                  'click' => "var extraurl='w2p/admin/index.php';alert(this.href+extraurl); window.open(this.href+extraurl, 'Website - '+ this.href); return false;",
                                  'sort_order' => $i++ * 10,
                                  'level' => 2,
                                  'url' => $baseUrl
                                  );
      
                  if(count($parentArr['view_sites']['children']) == $totalWebsiteCount){
                      $_websiteUrl['last'] = true;
                  } else {
                      $_websiteUrl['last'] = false;
                  }
      
                  $parentArr['view_sites']['children'][$j - 1] = $_websiteUrl;
      
                  $allStores = $app->getWebsite($app->getWebsite($_eachWebsiteId)->getId())->getStores();
                  $totalCount = count($allStores);
                  $i = 0;
                  foreach ($allStores as $_eachStoreId => $val){
                      $_websiteId = $app->getStore($_eachStoreId)->getWebsiteId();
                      if($_websiteId == $j){
                          $_storeName = 'View Admin';
                          $baseUrl = $app->getStore($_eachStoreId)->getUrl();
                          $_websiteUrl = array(
                                  'label' => $_storeName,
                                  'active' => false ,
                                  'click' => "var extraurl='w2p/admin/index.php';alert(this.href+extraurl); window.open(this.href+extraurl, 'Website - '+ this.href); return false;",
                                  'sort_order' => $i++ * 10,
                                  'level' => 2,
                                  'url' => $baseUrl
                                  );
      
                          if(count($parentArr['view_sites']['children'][$j - 1]['children']) + 1 == $totalCount or $totalCount == 0)
                              $_websiteUrl['last'] = true;
                              else
                              $_websiteUrl['last'] = false;
      
                          $parentArr['view_sites']['children'][$j - 1]['children'][$i] = $_websiteUrl;
                      }
                  }
              }
              return $parentArr;
          }
      }
      

      另外你需要去magento基础文件夹路径app-etc-modules-youemodule name(Inchoo_ExtendedMenu.xml)

      <?xml version="1.0"?>
      <config>
          <modules>
              <Inchoo_ExtendedMenu>
                  <active>true</active>
                  <codePool>local</codePool>
              </Inchoo_ExtendedMenu>
          </modules>
      </config>
      

      菜单创建结束。干杯。

      【讨论】:

      【解决方案4】:

      什么菜单?你说的是扩展吗?

      为了做到这一点,你有:System &gt; Magento connect &gt; Magento connect manager

      编辑:

      有一个扩展来管理这个,看看:Custom Menu Magento

      【讨论】:

      • 嗨@Flowen 我需要在magento 1.7.0.2 中创建自定义菜单模块。我该如何创建模块请告知
      • 已编辑,看看这个扩展
      • 我安装在 magento v 1.7.0.2 但致命错误:第 547 行的 D:\xampp\htdocs\projects\magento\app\Mage.php 中找不到类 'WP_CustomMenu_Helper_Data' 请指导我
      • 您是否在安装扩展程序后退出并从管理面板登录?如果仍然崩溃,请查看产品评论或支持,因为我不知道到底发生了什么。安装时总有人遇到这种问题。
      • 也许它与其他模块冲突...需要重写另一个块,在其 config.xml 中添加:&lt;blocks&gt; &lt;page&gt; &lt;rewrite&gt; &lt;html_topmenu&gt;WP_CustomMenu_Block_Navigation&lt;/html_topmenu&gt; &lt;/rewrite&gt; &lt;/page&gt; &lt;/blocks&gt;
      猜你喜欢
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      相关资源
      最近更新 更多