Answer the question
In order to leave comments, you need to log in
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
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
Use result_modifier.php
There you rebuild or filter your arResult, and pass it to the template already in the required form.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question