Skip to content

Instantly share code, notes, and snippets.

@ASDAFF
Forked from iredun/dep.php
Created October 31, 2018 14:00
Show Gist options
  • Save ASDAFF/285900044290f03303fb8b79e7644163 to your computer and use it in GitHub Desktop.
Save ASDAFF/285900044290f03303fb8b79e7644163 to your computer and use it in GitHub Desktop.
Получить список разделов и их подразделов в 1С - Битрикс
<?
$res = CIBlockSection::GetList(
Array('name' => 'asc'),
Array('IBLOCK_ID' =>'5' , 'ACTIVE' => 'Y')
);
while ($row = $res->GetNext())
{
echo $row['NAME'].'<br>';
$rsParentSection = CIBlockSection::GetByID($row['ID']);
if ($arParentSection = $rsParentSection->GetNext())
{
$arFilter = array('IBLOCK_ID' => $arParentSection['IBLOCK_ID'],'>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'],'<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'],'>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']); // выберет потомков без учета активности
$rsSect = CIBlockSection::GetList(array('left_margin' => 'asc'),$arFilter);
while ($arSect = $rsSect->GetNext())
{
echo '---'.$arSect['NAME'].'<br>';
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment