Sorting does not work
ernst - October 28, 2007 - 19:13
| Project: | Members |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | wmostrey |
| Status: | active |
Jump to:
Description
Hi I have problem sorting special land char
problem sort the surname, It dose not sort right when I have conutry specific characters as å, ä, ö and so on.......
Have one got any clue?
I have also tryed to write some simple code like this and it dosen't help mee
<?php
// Displays a list of all users including their profile images (all roles)
$header = array(
array('data' => t('Avatar'), 'field' => 'u.avatar'),
array('data' => t('User'), 'field' => 'u.name', 'sort' => 'asc'),
array('data' => t('Förnamn'), 'field' => 'u.fornamn'),
array('data' => t('Efternamn'), 'field' => 'u.efternamn')
);
$sql = 'SELECT u.uid, u.name, u.status, u.created, u.access FROM {users} u WHERE uid != 0 AND uid != 6';
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50);
$status = array(t('blocked'), t('active'));
while ($account = db_fetch_object($result)) {
$account = user_load(array('uid' => $account->uid));
if($account->picture){$account->picture = '<img src="'.$account->picture.'" height="125" width="125" border="1" alt="">';}
else{$account->picture = '<img src="files/pictures/default.gif" height="25" width="25" border="1" alt="">';}
$rows[] = array($account->picture, theme('username', $account), $account->profile_fornamn, $account->profile_efternamn);
}
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 50, 0);
print ($output);
?>
#1
#2
I can't help you with the above, but I have a similar bug to report.
I've created a "Page" with my members. When I sort by first name, last name, or username, it appears to sort it by the numerical user number (user/192) rather than by name itself. Actually, now that I've tested it further, I don't what it is sorting by.
Interestingly enough, when I sort by email it works as expected.
Was looking in function members_page, but not sure where to go from there.
This is a really useful module by the way!
Chris
#3
Yeah I just realized after importing 500 people that sorting by last name doesn't work:
http://itls.usu.edu/people?sort=asc&order=Last+Name
http://itls.usu.edu/people/alumni?sort=asc&order=Last+Name
But with our smaller listings it sorts fine:
http://itls.usu.edu/people/faculty?sort=asc&order=Last+Name
http://itls.usu.edu/people/staff?sort=asc&order=Last+Name
Here's what the sql query looks like: (sorting by "Last Name" for role id 7)
SELECT DISTINCT(u.uid) FROM {users} u INNER JOIN {users_roles} r ON u.uid=r.uid LEFT JOIN {profile_values} p ON u.uid=p.uid WHERE (p.fid = '3' OR p.fid IS NULL) AND r.rid IN ('7') AND u.status=1 ORDER BY p.value ASC LIMIT 50or it sends off to pager_query
#4
Looks it was user_import that corrupted things by adding a bunch of duplicate empty values in the profile_values table.
Sorting was fixed by running queries like
DELETE FROM `profile_values` WHERE value = ''
or for just one profile field: (replace 3 with id # of profile field)
DELETE FROM `profile_values` WHERE fid = 3 AND value = ''
#5
Is the profile_values table not supposed to have any empty values? I used the user-Import module and now I have a bunch of empty values. If there is no value for a profile field should it be absent from the table altogether?