如何在magento管理面板中添加菜单? [英] How to add menu in magento admin panel?
问题描述
我正在寻找有关如何执行以下操作的建议或信息.我想在magento管理面板中添加一个菜单.我正在尝试许多方法,但是没有工作.如何在管理面板中添加额外的一个菜单.请指教...
I am looking for some advice or information on how to do the following. I want to add one more menu in magento admin panel. I am trying many ways but not working. How can i add extra one menu in admin panel. please advise...
推荐答案
我正在创建一个模块.
I am creating one module.
info-公司名称文件夹
info - Company name folder
ExtendedMenu-模块名称
ExtendedMenu - Module Name
我要在modules文件夹中创建2个新文件夹.
I am creating 2 new folders in modules folder.
等&阻止
我正在创建config.xml文件的etc文件夹
etc folder I am creating config.xml file
<?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
Block -- 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)
Also you need to go to magento base folder path 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>
菜单创建结束.欢呼.
这篇关于如何在magento管理面板中添加菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!