M
M
mills2020-06-27 16:57:01
PHP
mills, 2020-06-27 16:57:01

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
}


Here is the getlist of what should be coming out:

$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>
<?
}


Tried to prescribe in the element output filter:
$arSection['ID'] = $isSectionId;
in_array($arSection['ID'], $isSectionId);

And I tried to prescribe the condition ...
But it didn’t work out as it should ...
Who can tell or give a direction how else you can do it, I will be very happy!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2020-06-28
@mills

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 question

Ask a Question

731 491 924 answers to any question