Last active
February 22, 2018 11:48
-
-
Save gdecider/510d11927317948fa8dc67c7478e1b21 to your computer and use it in GitHub Desktop.
Битрикс Ш меню двух уровневое
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? $APPLICATION->IncludeComponent( | |
"bitrix:menu", | |
"catalogmenu", | |
array( | |
"ALLOW_MULTI_SELECT" => "N", | |
"CHILD_MENU_TYPE" => "catalog", | |
"DELAY" => "N", | |
"MAX_LEVEL" => "3", | |
"MENU_CACHE_GET_VARS" => [], | |
"MENU_CACHE_TIME" => "3600", | |
"MENU_CACHE_TYPE" => "N", | |
"MENU_CACHE_USE_GROUPS" => "Y", | |
"ROOT_MENU_TYPE" => "catalog", | |
"USE_EXT" => "Y", | |
), | |
false | |
); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?> | |
<? | |
if(count($arResult) <=0 ) return; | |
$arItems = array(); | |
$curParent = null; | |
foreach ($arResult as $arItem) { | |
if ($arItem['DEPTH_LEVEL'] === 1 && $arItem['IS_PARENT']) { | |
$arItems[] = $arItem; | |
$curParent = &$arItems[count($arItems) - 1]; | |
} else { | |
if($arItem['DEPTH_LEVEL'] === 1) { | |
$arItems[] = $arItem; | |
} else { | |
$curParent['ITEMS'][] = $arItem; | |
} | |
} | |
} | |
unset($curParent); | |
$arResult = $arItems; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?> | |
<?if (!empty($arResult)):?> | |
<nav class="main-menu" id="js-main-menu"> | |
<ul> | |
<?foreach ($arResult as $arItem):?> | |
<li> | |
<a href="<?=$arItem['LINK']?>" class="<? echo $arItem['SELECTED'] ? 'active' : ''?> <?echo $arItem['IS_PARENT'] ? 'parent' : ''?>"><?=$arItem['TEXT']?></a> | |
<?if($arItem['IS_PARENT']) :?> | |
<ul> | |
<?foreach ($arItem['ITEMS'] as $arSubItem) :?> | |
<li><a href="<?=$arSubItem['LINK']?>"><?=$arSubItem['TEXT']?></a></li> | |
<?endforeach;?> | |
</ul> | |
<?endif;?> | |
</li> | |
<?endforeach;?> | |
</ul> | |
</nav> | |
<?endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment