Bitrix Site Manager


 string dir
 bool use_ext = false,
 string template_path = false

The method Init initializes the CMenu class instance (fills it with menu items). Returns true if the site directory contains the menu file .menu (the search is performed up the directory hierarchy starting from the folder dir). Otherwise, it returns false.


dir The folder from which the search for file .menu is performed (file with menu items and parameters ).
use_ext If true the file .menu type.menu_ext.php. will be included in addition to .menu to create the menu array. These files allow to handle the menu array $aMenuLinks as desired (for example: add menu items from information blocks).
Optional. False by default.
template_path Template used to display menu.

Optional. False by default, which means first searching for the template in the file /bitrix/templates/current site template ID/menu type.menu_template.php. If the template cannot be found, the file /bitrix/templates/.default/menu type.menu_template.php will be searched.

The following preset variables are available in the template:
  • $arMENU - copy of menu array;
  • $arMENU_LINK - link to the current menu array;
  • $TEXT - text of the current menu item;
  • $LINK - link on the current menu item;
  • $SELECTED - whether the menu item is currently selected;
  • $PERMISSION - access permission for the page specified in the $LINK field. Following values are possible:
    • D - access denied;
    • R - read access (view the file contents);
    • U - workflow (edit file in the workflow mode);
    • W - write (direct modification is allowed);
    • X - full access (both direct file modification and editing the access permission are allowed).
  • $ADDITIONAL_LINKS - additional links for menu highlighting;
  • $ITEM_TYPE - "D" stands for directory (if $LINK ends with "/"), otherwise "P" (page);
  • $ITEM_INDEX - menu item ordinal;
  • $PARAMS - parameters of menu items.
The menu template needs to have the following variables initialized:
  • $sMenuProlog - the HTML code to add before menu items;
  • $sMenuEpilog - the HTML code to add after menu items;
  • $sMenuBody - the HTML code describing a menu item;
  • $sMenu - the HTML code describing the whole menu (only for functions GetMenuHtmlEx). 

See Also


$lm = new CMenu("left");
$lm->Init($APPLICATION->GetCurDir(), true);
$lm->template = "/bitrix/templates/demo/left.menu_template.php";
echo $lm->GetMenuHtml();