Skip to content

Instantly share code, notes, and snippets.

@ostgals
Created September 22, 2017 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ostgals/e44882f1034a43d7634c2fab49b4306c to your computer and use it in GitHub Desktop.
Save ostgals/e44882f1034a43d7634c2fab49b4306c to your computer and use it in GitHub Desktop.
<?
$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