Last active
January 29, 2020 22:33
-
-
Save vladsold/62ec66fc28c2ec1f1be9aa607ba8b4dd to your computer and use it in GitHub Desktop.
Hide empty categories in 1c-bitrix
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
<? | |
//result_modifier.php | |
foreach ($arResult['SECTIONS'] as $key => $value) { | |
$arSelect = Array("ID"); | |
$sect = CIBlockElement::GetList( | |
Array("ID" => "DESC"), | |
Array("IBLOCK_ID" => #NUMBER_INFOBLOK#, | |
"ACTIVE" => "Y", | |
"SECTION_ID" => Array($arResult['SECTIONS'][$key]['ID']), | |
"INCLUDE_SUBSECTIONS" => 'Y', | |
"CATALOG_AVAILABLE" => "Y" | |
), | |
false, | |
Array("nTopCount" => 3), | |
$arSelect); | |
$count = 0; | |
while ($el = $sect->GetNextElement()) { | |
$count++; | |
if ($count > 1) break; | |
}; | |
if ($count < 1) unset($arResult['SECTIONS'][$key]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modify component catalog.section.list (move to local->components->bitrix) and modify result_modifier.php