S
S
serge_kolpakov2020-02-15 16:17:45
1C-Bitrix
serge_kolpakov, 2020-02-15 16:17:45

How to display elements in news.list starting from a certain element?

Hello,
In the news.list template, we display the elements
<?foreach($arResult["ITEMS"] as $arItem) { ?>
////
<?echo $arItem["NAME"]?>
////
<? } ?> It is
necessary to start the cycle not from the first element, but if $arItem["NAME"] is equal to "Moscow"
I know about sorting in the component and all that.
Here the task for the current city of contacts is to display it first.
Can anyone suggest a solution?
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Aisamiery, 2020-02-16
@Aisamiery

You were rightly told to use result_modifier.php in the folder of the news.list template you are using.
And then, as I understand it, you need the algorithm itself, you can even just loop through the ITEMS array, put your field in ascending order from 1 to N, but in the current city, set the value to 0 and then just use the sort function from php uasort, so you are the first will be the city you need, and the rest in the order that sorting was done by the component itself

A
Aliy Kunashev, 2020-02-15
@askunash

Use result_modifier.php
There you rebuild or filter your arResult, and pass it to the template already in the required form.

G
golddimas, 2020-10-13
@golddimas

use filters with complex logic. and then they will work correctly if the element has one city, and not several. https://dev.1c-bitrix.ru/support/forum/forum23/top...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question