Answer the question
In order to leave comments, you need to log in
How to get all subsections of an infoblock in Bitrix, including nested ones?
There is such a section tree
. The task is to get an array of names of all subsections of the "Tools and Equipment" section.
I do this:
$sections = CIBlockSection::GetList (
Array("ID" => "ASC"),
Array("IBLOCK_ID" => 1, "ACTIVE" => "Y", "SECTION_ID" => 10),
false,
Array('ID', 'NAME', 'CODE')
);
while($ar_fields = $sections->GetNext())
{
$sub_sections[] = $ar_fields['NAME'];
}
print_r($sub_sections);
Answer the question
In order to leave comments, you need to log in
Why didn't the example from the documentation fit?
https://dev.1c-bitrix.ru/api_help/iblock/classes/c...
<?
$rsParentSection = CIBlockSection::GetByID(1);
if ($arParentSection = $rsParentSection->GetNext())
{
$arFilter = array('IBLOCK_ID' => 2,'>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())
{
$arTest[] = $arSect;// получаем подразделы
}
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question