A
A
Andrey Bely2020-01-21 14:11:49
1C-Bitrix
Andrey Bely, 2020-01-21 14:11:49

How to sort in catalog.comment?

There are comments in the detailed view of the catalog.element product card, I have been trying to sort for an hour.
The fact is that the most recent comments are at the very end, but it is necessary that they be the very first, how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-07-13
@just_guy95

The blog.post.comment component is responsible for displaying reviews, its template is approximately /catalog.comments/templates/.default/bitrix/blog.post.comment/adapt, if not, find your template, here you need to edit its result_modifier.
Empirically, it was calculated that two arrays needed to be sorted (which is a bit strange, but like this)
- $arResult['CommentsResult'] - in a loop, sorted without problems using the usort function
- $arResult['PagesComment'] - in the reviews array are divided by pages, first you sort in reverse order - the krsort function, then, by analogy with the first array, you also do usort in the loop
- for usort you need to write your own comparison function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question