Sort by a profile field.

Yoonix - February 6, 2008 - 00:41
Project:Profile Plus
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

I actually store the first name and last name as extra fields. When I search for the similar names I get a list but it's ordered by the creation time (Ascending UID).

What I wanted to do is sort it by one of the field on the profile list or at least hard code it to sort it by first name or last name.

My solution is this and it seems be working but I don't know how to merge this into Search View.

Original Lines

    if ($items) {
      $finalsql = pager_query('SELECT uid FROM {users} WHERE uid IN ('.implode(', ', $items).') ');
        while ($pageditems = db_fetch_object($finalsql)) {
          $user = user_load(array('uid'=>$pageditems->uid));
          $profile_fields = profile_view_profile($user);

New Lines

    if ($items) {
      // order by first name
      $finalsql = pager_query('SELECT uid FROM {profile_values} WHERE uid IN ('.implode(', ', $items).') AND fid = 2 ORDER BY value');
        while ($pageditems = db_fetch_object($finalsql)) {
          $user = user_load(array('uid'=>$pageditems->uid));
          $profile_fields = profile_view_profile($user);

What I would like to do is some how get that '2' as a profile type field on the search form. I guess it's related to modifying the theme for the search_form. But I don't want to change all search forms just the profile plus user search forms.

 
 

Drupal is a registered trademark of Dries Buytaert.