Created
September 22, 2017 06:39
-
-
Save ostgals/e44882f1034a43d7634c2fab49b4306c 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
<? | |
$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