Skip to content

Instantly share code, notes, and snippets.

@ASDAFF
Forked from di7spider/fx_getSectionList.php
Created May 27, 2018 18:45
Show Gist options
  • Save ASDAFF/2a4b601ae660096d06db82e8a187c8b3 to your computer and use it in GitHub Desktop.
Save ASDAFF/2a4b601ae660096d06db82e8a187c8b3 to your computer and use it in GitHub Desktop.
1С-bitrix :: Возвращает разделы и вложенные подразделы в иерархическом виде
<?php
/** Возвращает разделы и вложенные подразделы в иерархическом виде */
function getSectionList($filter, $select)
{
$dbSection = CIBlockSection::GetList(
Array(
'DEPTH_LEVEL' => 'ASC',
'SORT' => 'ASC'
),
array_merge(
Array(
'ACTIVE' => 'Y',
'GLOBAL_ACTIVE' => 'Y'
),
is_array($filter) ? $filter : Array()
),
false,
array_merge(
Array(
'ID',
'IBLOCK_SECTION_ID'
),
is_array($select) ? $select : Array()
)
);
while( $arSection = $dbSection-> GetNext(true, false) ){
$SID = $arSection['ID'];
$PSID = (int) $arSection['IBLOCK_SECTION_ID'];
$arLincs[$PSID]['CHILDS'][$SID] = $arSection;
$arLincs[$SID] = &$arLincs[$PSID]['CHILDS'][$SID];
}
return array_shift($arLincs);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment