Here is an old solved issue about exposing the real name filter in views - - http://drupal.org/node/436564. I'm having the same issue for the drupal 7 version and I'm wondering wha the filter code should be? I need to be able to expose a real name filter in a view. I could use the actual profile field, but the problem with that is it won't find normal user names if they didn't fill that field out. In my particular case it's not required.

Comments

geerlingguy’s picture

Title: View Exposed Filter » Views Exposed Filter for RealName 7.x

I'm seconding this request - #436564: Support Views FILTER seems to have been committed to 6.x-1.3, but I don't see a filter in views on my D7 site using Views 7.x-3.x-dev.

dave reid’s picture

The 7.x-1.x version was a complete rewrite. Feel free to write a patch to re-add the Views integration.

joelstein’s picture

Status: Active » Needs work
StatusFileSize
new1.43 KB

Here's an initial attempt at Views support. It only adds the Realname field so you can include it in your Views. It does not add support for overriding existing Views.

geerlingguy’s picture

Status: Needs work » Reviewed & tested by the community

I've tested the patch above, and it works awesome for what I need:

  • I can now display a user's realname as a field in my views (instead of just the 'user name' form Views core).
  • I can add a Realname filter and filter my views by the user's realname.
  • I can add a sort by the realname (descending or ascending).

I would love to see even just this patch committed, so the basic views functionality is present. We could do extra stuff later...

dave reid’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Category: support » feature
Status: Reviewed & tested by the community » Fixed

Committed #3 to Git: http://drupalcode.org/project/realname.git/commit/b530d57 - we can have follow-ups for this as separate issues.

lemuelsantos’s picture

Category: feature » task
Priority: Normal » Major
Status: Fixed » Needs work

In my personal opinion the patch that was committed needs to be changed since the MAIN GOAL of this module is to show the REALNAME over the USERNAME take a look on the following actual code:

  $data['realname']['realname'] = array(
    'title' => t('Name'),
    'help' => t('The user or author realname.'),
    'field' => array(
      'handler' => 'views_handler_field_user',
      'click sortable' => TRUE,
    ),

Needs to be changed to this:

  $data['realname']['realname'] = array(
    'title' => t('Name'),
    'help' => t('The user or author realname.'),
    'field' => array(
      'handler' => 'views_handler_field_user_name',
      'click sortable' => TRUE,
    ),

On the "handler" line change from "views_handler_field_user" to this "views_handler_field_user_name"
I think it would make more sense...
Thanks.

lemuelsantos’s picture

StatusFileSize
new439 bytes

Attaching the patch file for the above comment.

Anandkumar’s picture

I can include the Realname field into the Fields and Filters section of Views. So far so good; but I want to expose this field as an auto-complete field. Like the one in Privatemsg module. Is there plan for this support?

Anandkumar’s picture

Never mind, I figured out how to do this, and it is pretty simple. I just added #autocomplete_path attribute to the filter element from my module file:

function mymodule_form_alter(&$form, &$form_state, $form_id){
/* ...
Other code
...
*/
// Alter the instances of 'Realname' fields in view search fields to be an autocomplete field.
    if ($form_id == 'views_exposed_form') {
      if($form['realname']){
        //debug ($form);
        $form['realname']['#autocomplete_path'] = 'realname/autocomplete';
        return $form;
      }
    }
}
WorldFallz’s picture

Issue summary: View changes

Slight correction to the code from #9 (there's no need to return $form):

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'views_exposed_form':
      // Convert realname exposed filter to autocomplete.
      if(isset($form['realname'])){
        $form['realname']['#autocomplete_path'] = 'realname/autocomplete';
      }
      break;
   case 'some_other_form':
     // etc
     break;
  }
}
WorldFallz’s picture

The code in #10 is correct, but it actually breaks the filter (it no longer works), because the sql it generates is searching for realname LIKE the username, which will fail. Still working on finding an acceptable workaround.