Skip to content

Instantly share code, notes, and snippets.

@expdev
Created December 18, 2013 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expdev/8017988 to your computer and use it in GitHub Desktop.
Save expdev/8017988 to your computer and use it in GitHub Desktop.
Битрикс. Вывести дерево разделов и элементов
<?
$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>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment