• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest sort thread replies by 'most likes'

gib

Active member
#1
I know there have been a few posts about sorting threads by likes, but it would be useful to be able to sort thread replies by 'most likes'

There are regular thread posts on one of my forums for caption competitions.
Users are asking if there is a way to vote or show the most liked replies at the top, with a secondary sort on chronological order
 

Digital Doctor

Well-known member
#2
Excellent idea !
There would be so many uses to this functionality.
I could see many uses for this at xenforo.com itself.

Should this be an addon or a core feature ?
Probably an addon.
 

Fuhrmann

Well-known member
#3
You can use order by first post likes:

http://xenforo.com/community/forums/have-you-seen/?order=first_post_likes&orderDirection=DESC

HTML:
public function prepareThreadFetchOptions(array $fetchOptions)
    {
        $selectFields = '';
        $joinTables = '';
        $orderBy = '';
 
        if (!empty($fetchOptions['order']))
        {
            $orderBySecondary = '';
 
            switch ($fetchOptions['order'])
            {
                case 'title':
                case 'post_date':
                case 'view_count':
                    $orderBy = 'thread.' . $fetchOptions['order'];
                    break;
 
                case 'reply_count':
                case 'first_post_likes':
                    $orderBy = 'thread.' . $fetchOptions['order'];
                    $orderBySecondary = ', thread.last_post_date DESC';
                    break;
 
                case 'last_post_date':
                default:
                    $orderBy = 'thread.last_post_date';
            }