Skip to content

Instantly share code, notes, and snippets.

@di7spider
Last active February 26, 2019 19:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save di7spider/4dd50d8b48a7a60e09ee to your computer and use it in GitHub Desktop.
Save di7spider/4dd50d8b48a7a60e09ee 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 $arLincs[0];
}
?>
@di7spider
Copy link
Author

/** Пример использования */
$arSections = getSectionList(
  Array(
    'IBLOCK_ID' => 25
  ),
  Array(
    'NAME',
    'SECTION_PAGE_URL'
 )
);

echo "<pre>";
 var_dump($arSections);
echo "</pre>";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment