Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?
$arSections = array_reduce($arResult["SECTIONS"], function($carry, $section){
if (empty($section["IBLOCK_SECTION_ID"])) { // depth 1
$section["LEVEL2_ITEMS"] = [];
$carry[$section["ID"]] = $section;
} else { // level
$parent_id = $section["IBLOCK_SECTION_ID"];
$carry[$parent_id]["LEVEL2_ITEMS"][] = $section;
}
return $carry;
});
?>
<div class="catalog-list">
<?foreach($arSections as $arSection){?>
<div class="catalog-list__title">
<h2><?=$arSection['NAME']?></h2>
</div>
<div class="catalog-list__items">
<?foreach($arSection["LEVEL2_ITEMS"] as $arSubSection){?>
<div class="catalog-list__item">
<a href="<?=$arSubSection['SECTION_PAGE_URL']?>"></a>
<div class="catalog-list__item-img" style="background-image: url(<?=$arSubSection['PICTURE']['SRC']?>);"></div>
<div class="catalog-list__item-name "><?=$arSubSection['NAME']?></div>
</div>
<?}?>
<div class="catalog-list__item-all">
<a href="<?=$arSection["SECTION_PAGE_URL"]?>"></a>
<div class="catalog-list__item-img" style="background-image: url(/images/all-catalog3.png);"></div>
<div class="catalog-list__item-name ">Всё насосное оборудование</div>
</div>
</div>
<?}?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.