Good day,
I can not solve the problem in any way with getting id articles filtered by date from several information blocks.
In principle, the task is trivial and implemented on many sites, when you need to display the latest messages from all sections in the order of the date of their publication, but I have no idea how to do this on bitrix.
I will give an example of what I want to implement:
There are 5 information blocks with $ iblock_id 24,31,45,55,67
In the first infoblock with $ iblock_id 24 the last article was written on January 9, her id 127 In the 2nd infoblock with $ iblock_id 31 the last article was written on January 6, her id 111 In the 3rd infoblock with $ iblock_id 45 the last article was written on January 1 her id 84 In the 4th information block with $ iblock_id 55 the last article was written on January 4, her id 105 In the 5th information block with $ iblock_id 67 the last article was written on January 3, her id 97
You need to get the id of the articles from the listed information blocks in descending order of the writing date.
Those.
- The id of the article written on January 9 (from the example id 127)
- The article id written on January 6th (from id 111)
- The article id written on January 4th (from id 105 example)
- The id of the article written on January 3 (from the example id 97)
- The id of the article written on January 1 (from the example id 84)
In the example, 5 information blocks are indicated, in reality there are much more of them and the number will grow.
I think that the logic should be as follows: We find the last published article in each of the information blocks given by $ iblock_id and pull out its id and date. Create an array.
Then we filter the array by date in descending order.
We get the last N elements of the array with dates and id.
How to get the id of the last article from a given information block I figured out
<? if (CModule::IncludeModule("iblock")): $iblock_id = 15; $i = 0; $my_elements = CIBlockElement::GetList ( Array("ID" => "desc"), Array("IBLOCK_ID" => $iblock_id), false, Array ("nTopCount" => 1), Array('ID') ); while($ar_fields = $my_elements->GetNext()) { if($i == 0) $id1=$ar_fields; } endif; ?> but how to implement a filter with an array I can not understand.
Thanks for attention. I will be glad to any help.