Exhaustion of sections and components of the Infoblock



  • There's an infoblock structure.

    1.Раздел 
    --1.1 Элемент 
    --1.2 Элемент 
    --1.3 Элемент 
    2.Раздел 
    --2.1 Элемент 
    --2.1 Элемент 
    

    Can you tell me how to get her out like that?

    if(CModule::IncludeModule("iblock")){
    

    $IBLOCK_ID = 6; // указываем из какого инфоблока берем элементы

    $arOrder = Array("SORT"=>"ASC"); // сортируем по свойству SORT по возрастанию
    $arSelect = Array("ID", "NAME", "IBLOCK_ID", "DETAIL_PAGE_URL");
    $arFilter = Array("IBLOCK_ID"=>$IBLOCK_ID, "ACTIVE"=>"Y");
    $res = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect);

    while($ob = $res->GetNextElement())
    {
    $arFields = $ob->GetFields(); // берем поля
    echo $arFields['NAME']."<br>";
    //echo "<pre>";var_dump($arFields);echo "</pre>";
    }

    echo "<br>";
    $arFilter = Array('IBLOCK_ID'=>$IBLOCK_ID, 'GLOBAL_ACTIVE'=>'Y');
    $list = CIBlockSection::GetList($arOrder, $arFilter, true);
    while($ar_result = $list->GetNext())
    {
    echo $ar_result['NAME'].'<br>';
    }}



  • Here's the answer, maybe who needs it.

    <? CModule::IncludeModule("iblock");
    

    $IBLOCK_ID = 6;
    $aMenuLinksNew = Array();

    $arFilter = array('IBLOCK_ID'=>$IBLOCK_ID, 'ACTIVE'=>'Y');
    $rsSect = CIBlockSection::GetList(Array("SORT"=>"ASC"), $arFilter, false, array("IBLOCK_ID", "ID", "NAME", "SECTION_PAGE_URL"));
    while ($arSect = $rsSect->GetNext())
    {
    $aMenuLinksNew[] = array(
    $arSect["NAME"],
    $arSect["SECTION_PAGE_URL"],
    array(),
    array("SECTION"=>true, "DEPTH_LEVEL"=>2),
    ""
    );
    $arSelect = Array("ID", "NAME", "DETAIL_PAGE_URL");
    $arFilterElem = Array('IBLOCK_ID'=>$IBLOCK_ID, "SECTION_ID"=>$arSect["ID"], "ACTIVE"=>"Y");
    $res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilterElem, false, false, $arSelect);
    if($arFields = $res->GetNext())
    {
    $aMenuLinksNew[] = array(
    $arFields["NAME"],
    $arFields["DETAIL_PAGE_URL"],
    array(),
    array("SECTION"=>false, "DEPTH_LEVEL"=>3),
    ""
    );
    }
    }
    $aMenuLinks = array_merge($aMenuLinks, $aMenuLinksNew);

    ? ation




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2