MyBB Community Forums

Full Version: [Tut] Sort Members by Thanks Received in your Member List
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Requirements: Thank You/Like You Plugin by G33K.

Aim: This tutorial will allow you to sort members by 'Thanks Received' in your memberlist.php page.
Demo: http://www.berlingoforum.co.uk/memberlist.php

Step 1

Access the file: inc/languages/english/memberlist.lang.php

Add this code wherever you like:
$l['sort_by_thanks'] = "Sort by: Thanks";
$l['thanks'] = "Thanks Received";

Step 2

Now browse to your: ACP >> Templates & Style >> Templates >> Your Theme >> Member List Templates

First, edit your "memberlist" template.

Find:
colspan="6"

Change to:
colspan="7"

Find:
<option value="postnum"{$sort_selected['postnum']}>{$lang->sort_by_posts}</option>

After this add:
<option value="thanks"{$sort_selected['thanks']}>{$lang->sort_by_thanks}</option>

Find:
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->lastvisit}</strong></span></td>

After this add:
<td class="tcat" width="10%" align="center"><span class="smalltext"><strong>{$lang->thanks}</strong></span></td>

Then, edit your "memberlist_user" template.

Find:
<td class="{$alt_bg}" align="center">{$user['lastvisit']}</td>

After this add:
<td class="{$alt_bg}" align="center">{$user['tyl_unumrcvtyls']} in {$user['tyl_unumptyls']} posts</td>

Step 3

Access the file: /memberlist.php

Find:
case "regdate":
			$sort_field = "u.regdate";
			break;

After this add:
case "thanks":
			$sort_field = "u.tyl_unumrcvtyls";
			break;

Which should leave you with something like:
switch($mybb->input['sort'])
	{
		case "regdate":
			$sort_field = "u.regdate";
			break;
		case "thanks":
			$sort_field = "u.tyl_unumrcvtyls";
			break;
		case "lastvisit":
			$sort_field = "u.lastactive";
			break;
		case "reputation":
			$sort_field = "u.reputation";
			break;
		case "postnum":
			$sort_field = "u.postnum";
			break;
		case "referrals":
			$sort_field = "u.referrals";
			break;
		default:
			$sort_field = "u.username";
			$mybb->input['sort'] = 'username';
			break;
	}

That should be everything.


Thanks to
Labrocca for his thread here which I used for part of this tutorial.
G33K for his plugin.