Views: 786 (Data available since 06.02.2017)
Last Modified: 11.09.2014

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
      ),
   ),
);

If you do not write your own module and there is a need to add an arbitrary option to the administrative menu, the array $aMenuLinks contained in the file /bitrix/admin/.left.menu.php be initialized with the relevant values.

Sample file /bitrix/admin/.left.menu.php adding an arbitrary menu option:

<?
// let us add the menu option “Import of machinery” to the section “Information Blocks"
$aMenuLinks = Array(
    Array(
        "Import of machinery", 
        "/bitrix/admin/equipment_import.php?lang=ru", 
        Array(), 
        Array(
            "ALT" => "Import of machinery from dbf files", 
            "SECTION_ID" => "iblock",
            "SORT" => "100"
        )
    )
);
?>




Courses developed by «Bitrix», Inc.