Thanks for all your help with my other issues related to this module. I have the RealName module enabled in my site and I really like it. The facet block (author) displays the authors’ usernames rather than their “real names.” In the search results page, the users’ real names are displayed in the teasers but right next that, the facet block (author) displays their usernames. Is there a way the facet block (author) can display their real names? I’m anal like that and most people would overlook something like this but I’m just seeking consistency in presentation. Thanks, again.

Comments

cpliakas’s picture

Hi mariner.

Thanks for posting. All of your support requests and bug reports are very much appreciated as they are helping to build a good knowledge base in the issue queue. Please keep them coming.

Regarding your use case, I now understand what you are trying to do and am sorry I didn't pick it up in your previous post. Search Lucene API exposes hook_luceneapi_facet_postrender_alter() which allows you to do things like alter the display name of the facets. As working example, the luceneapi_node module implements this hook at the bottom of the luceneapi_node.module file to convert the user ID's to the username. You could use the exact same technique in a custom module to override this value and display the user's real name instead. Let me look at the RealName module and I will post code on how to do this. It is important to note that the custom module the hook is implemented in will have to be heavier than Search Lucene Content so that it is executed afterwards.

Thanks,
Chris

cpliakas’s picture

Hey mariner.

I haven't tested this code out, but it should be a good starting point.


/**
 * Implementation of hook_luceneapi_postrender_alter().
 */
function mymodule_luceneapi_facet_postrender_alter(&$items, $realm, $module, $type = NULL) {
  if ('block' == $realm && isset($items['author']) {
    $values = array_keys($items['author']['items']);

    $sql = 'SELECT uid AS id, realname AS name'
         .' FROM {realname}'
         .' WHERE uid IN ('. db_placeholders($values, 'varchar') .')';

    // adds display names to items
    if ($result = db_query($sql, $values)) {
      while ($row = db_fetch_object($result)) {
        if (isset($items['author']['items'][$row->id])) {
          $items['author']['items'][$row->id]['text'] = $row->name;
        }
      }
    }
  }
}

Again, make sure your custom module is heavier than Search Lucene Content.

Hope this helps,
Chris

cpliakas’s picture

Status: Active » Closed (fixed)

Closing after a few weeks of inactivity.

aschiwi’s picture

Status: Closed (fixed) » Active

I have this same request but your code didn't work for me. I tried copying that part from the current module to change a few things, but no luck. My preferred solution would be without realname, since I'm really just using a theme_username in my template.php to grab a core profile field. But I do see how realname would be more flexible for everyone.

cpliakas’s picture

Status: Active » Closed (fixed)