MyBB Community Forums

Full Version: Memberlist default sorting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I was trying to make my memberlist sorted by ratings by default, I tried to move code around but couldn't get it to work. Any guide to achieve this would be highly appreciated Smile
Once you have installed the "Sort By Rating" mod, find this block of code...

else
{
	$by = "regdate";
}

...and replace it with this...

else
{
	$by = "rating";
}

That's all there is to it. Smile
So far so good. Thanx for the help man. But I need some more. I also want to display members' ratings (as they appear on profile page) on the memberlist. Thanx in advance Smile

PS: Are you still travelling or reached home?Smile
As of today I don't have any more travelling, and boy does it feel good to be home. Smile

Note: The code below has been edited to take into account the bug fixes posted later in this thread. If you follow the code below, you do not need to fix the code errors in later posts. Smile

Last edit: 23rd September, 2004.

To display member ratings on the memberlist, try the following...

Open: memberlist.php

Find:
while($users = $db->fetch_array($query))
{

After, add:
if($users['rating'])
{
    $rateinfo = explode("|", $users['rating']);
    $users['rating'] = round($rateinfo[0] / $rateinfo[1]);
    for($i = 1; $i <= $users['rating']; $i++)
    {
        $rating .= "<img src=\\"$theme[imgdir]/star.gif\\" border=\\"0\\" title=\\"$users[rating] out of 5\\" />";
    }
}
else
{
    $rating = "Not Yet Rated";
}

Find:
eval("\\$member .= \\"".$templates->get("memberlist_row")."\\";");

After, Add:
unset($rating);

Then from your admin control panel, look for this code in the "memberlist" template:

<tr>
<td class="thead"><b>Username:</b></td>
<td class="thead" align="center"><b>E-mail:</b></</td>
<td class="thead" align="center"><b>Website:</b></</td>
<td class="thead"><b>Location:</b></</td>
<td class="thead" align="center"><b>Joined:</b></</td>
<td class="thead"><b>Posts:</b></</td>
</tr>

Replace the above with this:

<tr>
<td class="thead"><b>Username:</b></td>
<td class="thead"><b>Rating:</b></td>
<td class="thead" align="center"><b>E-mail:</b></</td>
<td class="thead" align="center"><b>Website:</b></</td>
<td class="thead"><b>Location:</b></</td>
<td class="thead" align="center"><b>Joined:</b></</td>
<td class="thead"><b>Posts:</b></</td>
</tr>

Next, look for these two lines in the same template:

<form action="memberlist.php" method="post">
<td align="center" colspan="6" class="trow2">

Highlight, and replace them with these two lines:

<form action="memberlist.php" method="post">
<td align="center" colspan="7" class="trow2">

Then open your "memberlist_row" template, and highlight everything. Replace it with this:

<tr>
<td class="trow1"><a href="member.php?action=profile&uid=$users[uid]">$users[username]</a></td>
<td class="trow2">$rating</td>
<td class="trow1">$useremail</td>
<td class="trow2">$usersite</td>
<td class="trow1">$users[location]</td>
<td class="trow2">$users[regdate]</td>
<td class="trow1">$users[postnum]</td>
</tr>

I haven't had time to test the above changes yet, but I don't see any reason for the process not to work. Feel free to try and let me know how things turn out. Smile
I changed the memberlist code but getting he following is the error:
Parse error: parse error, unexpected T_VARIABLE in /home/chiefsaab/public_html/forum/memberlist.php on line 112 
Are you sure you have copied the code correctly? I've just tested and I'm not experiencing this problem. I am however experiencing a few other problems and the fixes are posted below.

The block you should add to memberlist.php should actually look like this:

if($users['rating'])
{
	$rateinfo = explode("|", $users['rating']);
	$users['rating'] = round($rateinfo[0] / $rateinfo[1]);
	for($i = 1; $i <= $users['rating']; $i++)
	{
		$rating .= "<img src=\\"$theme[imgdir]/star.gif\\" border=\\"0\\" title=\\"$users[rating] out of 5\\" />";
	}
}
else
{
	$rating = "Not Yet Rated";
}

Additionally in memberlist.php, you need to find this line...

eval("\\$member .= \\"".$templates->get("memberlist_row")."\\";");

...and add this one below it...

unset($rating);

Finally, the "memberlist_row" template should actually look like this:

<tr>
<td class="trow1"><a href="member.php?action=profile&uid=$users[uid]">$users[username]</a></td>
<td class="trow2">$rating</td>
<td class="trow1">$useremail</td>
<td class="trow2">$usersite</td>
<td class="trow1">$users[location]</td>
<td class="trow2">$users[regdate]</td>
<td class="trow1">$users[postnum]</td>
</tr>

Let me know if you still have problems. Smile
Yeah it's working now. Thanx a lot Smile But tell me one thing. Do we have any problem with the pethod that collects or store or show ratings for a member? I mean when I see my memberlist sorted byt ratings, two members with 14 ratings each are on top of the list while two other with 19 ratings and 24 ratings are somewhere int he middle of the list.

Another thing, those two with total ratings 14, one has 5 stars to his credit while the second one also with 14 ratings, has only 3 stars. Do you think everything is working ok?
I've not played with the rating systems much so I'm not to sure.

I'll have a play around and see what I can find out. Smile
Due to some problems, I had to reinstall my board a got a new copy that inculded Service Pack 1. After that I manipulated the memberlist.php and memberlist_row.php files according to guide in this thread, but now I am the ratings in figures. See attachment. MM your help please Sad
Eek. :eek:

I'm actually on my way to bed now (very long day Sad), but I'll look into this tomorrow and post a fix for you. Smile
Pages: 1 2