2013-04-24 98 views

回答

0

我创建一个模块。

信息 - 公司名称的文件夹

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名称(Inchoo_ExtendedMenu.xml)

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

菜单创建结束。干杯。

+0

,我不知道你的答案工作正常或没有,因为我没有尝试这个。但我对你的账户有一个疑问。请参阅本网站http://meta.stackexchange.com/questions/190267/why-does-this-user-have-posts-that-appear-to-be-older-than-their-account#190267 – DRAJI 2013-07-25 05:48:29

+0

Hi @ DRAJI你的疑问已被清除?或检查你的链接http://meta.stackexchange.com/questions/190267/why-does-this-user-have-posts-that-appear-to-be-older-than-their-account#190267 – 2013-07-26 05:56:11

-2

什么菜单?你在谈论延期吗?

为了做到这一点,你必须:System > Magento connect > Magento connect manager

编辑:

即使世界的延伸来管理这个,一起来看看:Custom Menu Magento

+0

嗨@Flowen我需要在magento 1.7.0.2中创建自定义菜单模块。我如何创建模块请指教 – 2013-04-24 08:34:25

+0

编辑,看看这个扩展 – Flowen 2013-04-24 08:42:30

+0

我安装在magento v 1.7.0.2但致命的错误:类'WP_CustomMenu_Helper_Data'找不到D:\ xampp \ htdocs \ projects \ magento \ app \ Mage.php在线547请指导我 – 2013-04-24 09:33:26

6

如果这是你的自定义模块,你需要什么要做的是在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> 

ex充足的上面会添加一个新的项目到报告标签,并在控制器中触发一个动作来做某件事。希望这可以帮助。

+0

仍然适用于1.9 – TT120 2016-04-18 11:48:45

0

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

相关问题