2013-04-24 107 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

相關問題