Answer the question
In order to leave comments, you need to log in
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;
}
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question