View Full Version : Sort member list by Location
dknelson
11-12-2005, 09:44 AM
Sorry if this has already been requested. I did a search and didn't find it.
I would like to be able to sort the members list by location. To be able to click the "Location" field just as you do the "posts", "alphabetical", etc. headers.
I've seen this requested all the way back to VBulleting 2 something but have never really seen it done. Is it just not feasible?
Don
boatdesign
11-23-2005, 09:21 PM
Excellent idea - this would be very useful for many forums.
zendiver
12-17-2005, 02:59 AM
I know quite a few have been asking for this and I knew that I had it before in an earlier version (3.0.3) so I thought I would give it a go and see if I could get it to work in 3.5.2 and it does.
(Thanks to Stuart for the direction over a year ago)
1 File to Edit
1 Template to Edit
In memberlist.php you need to add a case, to the switch so as you can sort by location.
case 'location':
$sqlsort = 'userfield.field2';
break;
So in forums/memberlist.php on or about line 356...
FIND:
switch ($sortfield)
{
case 'username':
$sqlsort = 'user.username';
break;
REPLACE WITH:
switch ($sortfield)
{
case 'location':
$sqlsort = 'userfield.field2';
break;
case 'username':
$sqlsort = 'user.username';
break;
If the customfields radio button is enabled (YES) in AdminCP Options->User Listing & Profile Viewing->Member List Enabled, then the 5 fields from the userfield table are included and put in an array, $profileinfo. Later, if $profileinfo is an array and $vboptions['customfields'] is true, there's some code that pulls the extra table headings from template memberlist_results_header.
There's more than 1 way to do this, but for ease, I would add a line of code that sets a condition if the field is Location (field2)
$show['field2'] = iif($customfield['varname'] == 'field2', true, false);
In forums/memberlist.php on or about line 811...
FIND:
foreach ($profileinfo AS $index => $customfield)
{
$totalcols++;
$customfield = $customfield['title'];
eval('$customfieldsheader .= "' . fetch_template('memberlist_results_header') . '";');
}
}
REPLACE WITH:
foreach ($profileinfo AS $index => $customfield)
{
$show['field2'] = iif($customfield['varname'] == 'field2', true, false);
$totalcols++;
$customfield = $customfield['title'];
eval('$customfieldsheader .= "' . fetch_template('memberlist_results_header') . '";');
}
}
To set the condition, that is used in the template memberlist_results_header
so that in memberlist_results_header you could change
FIND:
<td class="thead" nowrap="nowrap">$customfield</td>
REPLACE WITH:
<td class="thead" nowrap="nowrap"><if condition="$show['field2']"><a href="$sorturl&order=DESC&sort=location&pp=$perpage&ltr= $ltr$usergrouplink">$customfield</a> $sortarrow[location]<else />$customfield</if></td>
Be warned, its not a search option for a reason, its a slow query, sorting on location and without an index it needs to do a full table scan. With a BIG database, it could be taxing.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.