Нашел отличный скрипт для вывода всего дерева подразделов в Битриксе. По сравнению со всеми ранее найденными решениями это самое лучшее.
$iblock = 3; $res = CIBlockSection::GetList( Array("LEFT_MARGIN" => "ASC"), Array("IBLOCK_ID" => $iblock, "ACTIVE" => "Y", "GLOBAL_ACTIVE" => "Y"), true, Array("ID", "NAME", "DESCRIPTION", "PICTURE","SECTION_PAGE_URL") ); while ($arSection = $res->GetNext()) { $iCnt2 = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $iblock, "ACTIVE" => "Y", "SECTION_ID" => $arSection['ID']), array()); if ($iCnt2 == 0) { echo '<b><a href="' . $arSection['SECTION_PAGE_URL'] .'">' .$arSection['NAME'] . "</a></b><br>"; continue; } echo '<ul><b><a href="' . $arSection['SECTION_PAGE_URL'] .'">' .$arSection['NAME'] . "</a></b><br>"; $arSelect = Array("ID", "NAME", "DATE_ACTIVE_FROM"); $iCnt = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $iblock, "ACTIVE" => "Y", "SECTION_ID" => $arSection['ID']), false, Array(), $arSelect); while ($ob = $iCnt->GetNextElement()) { $arFields = $ob->GetFields(); foreach ($arResult['ITEMS'] as $cell => $arElement) { if ($arFields['ID'] == $arElement['ID']) { echo '<li><a href="' . $arElement['DETAIL_PAGE_URL'] .'">' . $arElement['NAME'] . "</a></li>"; } } } echo "</ul>"; }