A
A
ArrayPop2020-07-19 21:59:35
1C-Bitrix
ArrayPop, 2020-07-19 21:59:35

How to create a menu and submenu in Bitrix for custom links?

How to create a menu without going to the sections of the site? For example, my top menu link is not a section, how can I create a submenu for it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-07-20
@ArrayPop

The menu items have an advanced setting, where you can add additional options for each item. parameters
5f1530c991831596350843.jpeg
Well, for example, for the first-level link, set the parameter PARENT = CHILD_1
For second-level links, set the parameter CHILD = CHILD_1
In the menu component, all these parameters fall into the PARAMS array of each item, well, and there in result_modifier.php you compose as you need, figuratively depends already how you want to make the output in template.php
Example

foreach($arResult as $key => &$arItem) {
  if(isset($arItem['PARAMS']['PARENT']) && $arItem['PARAMS']['PARENT']) {
    $parents[$arItem['PARAMS']['PARENT']] = &$arItem;
  }
  
  if(isset($arItem['PARAMS']['CHILD']) && $arItem['PARAMS']['CHILD']) {
    $parents[$arItem['PARAMS']['CHILD']]['CHILDS'][$key] = $arItem;
    unset($arResult[$key]);
  }
}

If you need more than 2 levels, you can take this matter into a function and call it recursively

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question