Views: 14562
Last Modified: 10.10.2024
The menu of the administrative part is displayed by the standard function CMain::GetMenuHtmlEx.
The menu template is stored in the file /bitrix/modules/main/interface/.left.menu_template.php
The main file collecting menu options is /bitrix/modules/main/interface/.left.menu.php
. Here, all the files contained in /bitrix/modules/module ID/admin/menu.php
are examined. Each such file contains a definition of the array $aModuleMenuLinks containing the menu options of the relevant module. All of these arrays will be later unified into a standard array $arMenuSections that contains information about all the menu options.
Sample menu structure using the example of \bitrix\modules\main\admin\menu.php
$aMenu[] = array(
"parent_menu" => "global_menu_settings",
"sort" => 1800,
"text" => GetMessage("MAIN_MENU_TOOLS"),
"title" => GetMessage("MAIN_MENU_TOOLS_TITLE"),
"url" => "tools_index.php?lang=".LANGUAGE_ID,
"icon" => "util_menu_icon",
"page_icon" => "util_page_icon",
"items_id" => "menu_util",
"items" => array(
array(
"text" => GetMessage("MAIN_MENU_SITE_CHECKER"),
"url" => "site_checker.php?lang=".LANGUAGE_ID,
"more_url" => array(),
"title" => GetMessage("MAIN_MENU_SITE_CHECKER_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_FILE_CHECKER"),
"url" => "file_checker.php?lang=".LANGUAGE_ID,
"more_url" => array(),
"title" => GetMessage("MAIN_MENU_FILE_CHECKER_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_PHPINFO"),
"url" => "phpinfo.php?test_var1=AAA&test_var2=BBB",
"more_url" => array("phpinfo.php"),
"title" => GetMessage("MAIN_MENU_PHPINFO_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_SQL"),
"url" => "sql.php?lang=".LANGUAGE_ID."&del_query=Y",
"more_url" => array("sql.php"),
"title" => GetMessage("MAIN_MENU_SQL_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_PHP"),
"url" => "php_command_line.php?lang=".LANGUAGE_ID."",
"more_url" => array("php_command_line.php"),
"title" => GetMessage("MAIN_MENU_PHP_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_AGENT"),
"url" => "agent_list.php?lang=".LANGUAGE_ID,
"more_url" => array("agent_list.php", "agent_edit.php"),
"title" => GetMessage("MAIN_MENU_AGENT_ALT"),
),
array(
"text" => GetMessage("MAIN_MENU_DUMP"),
"url" => "dump.php?lang=".LANGUAGE_ID,
"more_url" => array("dump.php", "restore_export.php"),
"title" => GetMessage("MAIN_MENU_DUMP_ALT"),
),
(strtoupper($DBType) == "MYSQL"?
Array(
"text" => GetMessage("MAIN_MENU_REPAIR_DB"),
"url" => "repair_db.php?lang=".LANGUAGE_ID,
"more_url" => array(),
"title" => GetMessage("MAIN_MENU_REPAIR_DB_ALT"),
)
:null
),
($USER->CanDoOperation('view_event_log')?
Array(
"text" => GetMessage("MAIN_MENU_EVENT_LOG"),
"url" => "event_log.php?lang=".LANGUAGE_ID,
"more_url" => array(),
"title" => GetMessage("MAIN_MENU_EVENT_LOG_ALT"),
)
:null
),
),
);
An item of administrative menu can be added via the event OnBuildGlobalMenu.
If you are writing your own module, you can use /bitrix/modules/ID_module/admin/menu.php
to add arbitrary options to the administrative menu.
Old method of generating a menu
|
Array structure $aModuleMenuLinks:
Array
(
[0] => Array
(
[0] => menu item header
[1] => menu item link
[2] => Array
(
[0] => additional link to Highlight menu item 1
[1] => additional link to Highlight menu item 2
...
[N] => additional link to Highlight menu item N
)
[3] => Array
(
[ALT] => popup hint at the menu item
[SECTION_ID] => unique ID for menu section,
accepts value equal to module ID,
or one of the following:
FAVORITE - "Favourites" section
GENERAL - "Users" section
MAIN - "System settings" section
[SEPARATOR] => "Y" - menu item that is menu section header
[SORT] => menu section sorting
for other menu sections (only when SEPARATOR=Y)
[ICON] => link to small icon used
in the menu section header (only when SEPARATOR=Y)
[BIG_ICON] => link to large icon for use
on the "Desktop" page (only when SEPARATOR=Y)
[INDEX_PAGE] => link at the BIG_ICON (only when SEPARATOR=Y)
)
)
[1] => Array( -//- )
[2] => Array( -//- )
...
[M] => Array( -//- )
)
Example of file /bitrix/modules/support/admin/menu.php that determines "Technical support" module menu:
<?
// connect language file
IncludeModuleLangFile(__FILE__);
// determine access permissions for current user
$SUP_RIGHT = $APPLICATION->GetGroupRight("support");
// when access permissions are not restricted
if($SUP_RIGHT>"D")
{
// add menu items depending on access permissions
$aModuleMenuLinks[] = Array(
GetMessage("SUP_M_SUPPORT"),
"",
Array(),
Array(
"SEPARATOR" => "Y",
"SORT" => 1000,
"ICON" => "/bitrix/images/support/mnu_support.gif",
"BIG_ICON" => "/bitrix/images/support/support.gif",
"INDEX_PAGE" => "/bitrix/admin/ticket_desktop.php?lang=".LANGUAGE_ID."&set_default=Y"
)
);
if ($SUP_RIGHT>="T")
{
$aModuleMenuLinks[] = Array(
GetMessage("SUP_M_REPORT_TABLE"),
"/bitrix/admin/ticket_desktop.php?lang=".LANGUAGE_ID."&set_default=Y",
Array("/bitrix/admin/ticket_desktop.php"),
Array("ALT"=>GetMessage("SUP_M_REPORT_TABLE_ALT"))
);
}
$aModuleMenuLinks[] = Array(
GetMessage("SUP_M_TICKETS"),
"/bitrix/admin/ticket_list.php?lang=".LANGUAGE_ID."&set_default=Y",
Array(
"/bitrix/admin/ticket_list.php",
"/bitrix/admin/ticket_edit.php",
"/bitrix/admin/ticket_message_edit.php"
),
Array("ALT"=>GetMessage("SUP_M_TICKETS_ALT"))
);
if ($SUP_RIGHT>="T")
{
$aModuleMenuLinks[] = Array(
GetMessage("SUP_M_REPORT_GRAPH"),
"/bitrix/admin/ticket_report_graph.php?lang=".LANGUAGE_ID."&set_default=Y",
Array("/bitrix/admin/ticket_report_graph.php"),
Array("ALT"=>GetMessage("SUP_M_REPORT_GRAPH_ALT"))
);
}
if ($SUP_RIGHT>="V")
{
$aModuleMenuLinks[] = Array(
GetMessage("SUP_M_CATEGORY"),
"/bitrix/admin/ticket_dict_list.php?lang=".LANGUAGE_ID."&find_type=C&set_filter=Y",
Array(
"/bitrix/admin/ticket_dict_edit.php?find_type=C",
"/bitrix/admin/ticket_dict_list.php?find_type=C"
)
);
}
}
?> |