Answer the question
In order to leave comments, you need to log in
How to distribute items across GetList sections?
Hello!
I have infoblock #1 with sections and each section has elements. Each section has a link to other sections in infobook #2.
I
need infoblock No. 1 to show the elements of a section in another section of info block No. 2 where the link in info block No. 1 section has a property link ...
I hope I didn’t explain it intricately ...
the page where the sections of infoblock No. 2 in each section displays the same elements, but should be different.
//Общая информация гетлистов
$IBLOCK_ID = 13;
$arOrder = array("SORT" => "DESC");
$arSelect = Array("ID", "IBLOCK_ID", "*", "UF_*");
//Разделы
$arFilter = Array("IBLOCK_ID" => $IBLOCK_ID);
$resSection = CIBlockSection::GetList(array(), $arFilter, false, $arSelect);
while($arSections = $resSection->GetNext()){
$isSectionId[] = $arSections['UF_SECTION_ID']; //Свойство привязки к разделу инфоблока №2
}
$arFilters = Array("IBLOCK_ID" => $IBLOCK_ID);
$resItem = CIBlockElement::GetList($arOrder, $arFilters, false, false, $arSelect);
while($ob = $resItem->GetNextElement()){
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
?>
<pre>
<?print_r($arFields['NAME']);?>
</pre>
<?
}
Answer the question
In order to leave comments, you need to log in
Based on the results of communication in the comments, we slightly changed the query code and the sampling algorithm.
The problem was in the algorithms.
I would recommend additionally:
1) Divide the template into 2 parts: result_modifier.php (logic, queries, result processing) and template.php (purely visual display), otherwise you will get confused.
2) Check that $arParams['PARENT_SECTION'] is not null (not null, 0, false is not an empty array), otherwise there is a chance to get all sections
3) Do not use queries in a loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question