N
N
Norbyt2015-08-19 21:51:54
1C-Bitrix
Norbyt, 2015-08-19 21:51:54

Why are sections of the infoblock not displayed?

There is an infoblock with sections, you need to display them in the form of a tree, but even I can’t do it.
Here is the code itself:

if(CModule::IncludeModule("iblock"))
{
  $arFilter = array('IBLOCK_ID' => $arResult["ID"]);
  $arSelect = array('NAME');
  $arLis = CIBlockSection::GetList(Array("left_margin"=>"asc"), $arFilter,false,$arSelect,false);
  while($arRes = $arLis->GetNext())
  	{
  		echo $arRes;
  	}

}

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Varenikov, 2015-08-20
@warenikov

echo $arRes["NAME"];
$arRes is an array with sections if the CIBlockSection::GetList function worked correctly.
In general, take yourself such a function for debugging and displaying an array on the screen, it always helps me:

/**
     * @param array $what
     * @param bool $exit
     *
     * Вывод массива на экран.
     * Если $exit равен true - завершаем выполнение.
     */
function pre($what, $exit = false)
    {
      if(count($what) == 0){
        echo "array is empty";
        return false;
      }

        echo '<pre>';
        print_r($what);
        echo '</pre>';
        if($exit) exit;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question