ApacheSolr Search Integration has a facet for filtering searches by username, and currently it requires some code in one's theme to override the default username display. Could Realname more easily integrate (out of the box, if possible) with Solr's block?

See: #414078: Use Real Names in 'Filter by author' block

Comments

imDhaval’s picture

+1

scor’s picture

subscribe

geerlingguy’s picture

Just posting the working code I used in ApacheSolr's queue here (this code goes in your template.php):

/**
 * Implementation of hook_theme().
 */
function THEMENAME_theme(&$existing, $type, $theme, $path) {
  return array(
    // Apachesolr's username search facet
    'apachesolr_breadcrumb_uid' => array(
      'arguments' => array('field' => NULL),
    ),
  );
}

/**
 * Theme function to change name of ApacheSolr Search's user facet.
 */
function THEMENAME_apachesolr_breadcrumb_uid($field) {
  $uid = $field;
  if ($uid == 0) {
    return variable_get('anonymous', t('Anonymous'));
  }
  else {
    $user = realname_get_user($uid);
    $realname = $user->name;
    return($realname);
  }
}
scor’s picture

THEMENAME_apachesolr_breadcrumb_uid() for Drupal 7:

function THEMENAME_apachesolr_breadcrumb_uid($vars) {
  $field = $vars['field'];
  if ($field['#value'] == 0) {
    return variable_get('anonymous', t('Anonymous'));
  }
  else {
    $account = new stdClass;
    $account->uid = $field['#value'];
    return realname_load($account);
  }
}

edit: updated code, this one should be more performant

coderintherye’s picture

Hi, please repost this as a patch and then I will review it and possibly see if I can get a commit in on it. However, we'll have to have some discussion whether we should be adding code to support specific modules because that is a slippery slope, how will we define which modules are important enough to add integration for? Over in http://drupal.org/node/517844 we are trying to move some code out in order to define a hook for modules instead of supporting them explicitly. Granted, that would not apply for the current case.

Anyways, if someone wants to post a patch, that will get us closer to moving it into code. If you need info on creating patches, you can find it here: http://drupal.org/patch/create

scor’s picture

@nowarninglabel: the codes snippets above are not for the realname module but instead to be added to your theme's template.php.

coderintherye’s picture

@scor That is exactly why I asked to be reposted as a patch. Either that or we should close this issue, as it is currently a feature request.

hass’s picture

Issue summary: View changes
Status: Active » Closed (outdated)