Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flayder/562019da58b59bc75f7373eadbeead78 to your computer and use it in GitHub Desktop.
Save flayder/562019da58b59bc75f7373eadbeead78 to your computer and use it in GitHub Desktop.
<? if (!empty($arResult)) { ?>
<ul class="open">
<?
$previousLevel = 0;
$i = 0;
foreach ($arResult as $arItem) {
if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel)
echo str_repeat('</ul><div class="btn"></div></li>', ($previousLevel - $arItem["DEPTH_LEVEL"]));
?>
<? if ($arItem["IS_PARENT"]) { ?>
<li class="parent<?=($arItem['SELECTED'])?' general curr open':''?>">
<a href="<?=$arItem['LINK']?>"><?=$arItem['TEXT']?></a>
<ul>
<? } else { ?>
<li class="<?=($arItem['SELECTED'])?' general curr open':''?>">
<a href="<?=$arItem['LINK']?>"><?=$arItem['TEXT']?></a>
</li>
<? } ?>
<? $previousLevel = $arItem["DEPTH_LEVEL"] ?>
<? } ?>
<? if ($previousLevel > 1) echo str_repeat('</ul><div class="btn"></div></li>', ($previousLevel-1)); ?>
</ul>
<? } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment