Last active
June 19, 2018 15:14
-
-
Save gdecider/cf89473a0473976f4b322a64152440fc 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(); ?> | |
<? | |
$oldDepthLevel = 0; | |
$arResult[count($arResult) - 1]['IS_LAST'] = true; | |
foreach ($arResult as $arLink) { | |
$currentDepthLevel = $arLink["DEPTH_LEVEL"]; | |
$isParent = $arLink["IS_PARENT"]; | |
if ($oldDepthLevel < $currentDepthLevel) { | |
if ($oldDepthLevel === 0) { | |
echo '<ul class="menu-catalog__list">'; | |
} else { | |
echo '<ul>'; | |
} | |
} | |
if ($oldDepthLevel > $currentDepthLevel) { | |
for ($i = $currentDepthLevel; $i < $oldDepthLevel; $i++) { | |
echo '</ul></li>'; | |
} | |
} | |
if ($isParent) { | |
echo '<li class="parent ' . ($arLink['SELECTED'] ? 'active' : '' ) .'">'; | |
} else { | |
echo '<li' . ($arLink['SELECTED'] ? ' class="active"' : '' ) .'>'; | |
} | |
?> | |
<a href="<?= $arLink['LINK'] ?>"><?= $arLink['TEXT'] ?></a> | |
<? | |
if (!$isParent) { | |
echo '</li>'; | |
} | |
if ($arLink['IS_LAST']) { | |
echo '</ul>'; | |
} | |
$oldDepthLevel = $currentDepthLevel; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment