Sort descending the comments/posts

sirready

Member
Registered
Joined
Feb 17, 2023
Messages
7
Points
3

Reputation:

Hello,
I was wondering how I can achieve the option to sort in reverse (desc) the posts in a specific thread.
I was playing around in the thread_view template and post_macros.


The hard part is to get the reverse, I've tried numerous options such as:

Code:
{set $sortedPosts = $posts|sort_by('post_date', 'desc')}

<xf:foreach loop="$posts|reverse" value="$post">

<xf:foreach loop="$posts" start="{{ count($posts) }}" end="1" step="-1" value="$post">

or

Code:
<xf:foreach loop="$posts" from="{$posts|length}" to="1" step="-1" value="$i">
<xf:set var="$post" value="$posts[$i - 1]" /> 

the post macro here

</xf:foreach>

However, nothing works. I was wondering if someone did this and can give me an idea, thanks.
 

Zer01ne

Collaborate
Collaborate
Registered
Joined
Nov 25, 2022
Messages
667
Points
253

Reputation:

I am not clear about what you want.
I Think you are looking for this
1678876746109.png

and if that so, you will get it on your node advance settings.
 

sirready

Member
Registered
Joined
Feb 17, 2023
Messages
7
Points
3

Reputation:

This is for the "thread" list inside a category/forum.
I need the comments within a thread.

Imagine this thread. I need this comment (which is the latest one ATM), to be at the top of the comment list.
For example, a button like sort ascending/descending would work

1678899528773.png
 
Top