The current results displayed in the autocomplete suggestions are based on which terms would return the most results. A site may want to prioritize certain suggestions even if they have fewer (but more important) results.

A custom module would be able to alter the suggestions if this module added a drupal_alter() in apachesolr_autocomplete_callback() before drupal_json_output($result).

For example:

// Invoke any modules that want to alter the results to show.
// function MODULENAME_apachesolr_autocomplete_results_alter(&$results) { }
drupal_alter('apachesolr_autocomplete_results', $results);

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DeFr’s picture

Status: Active » Needs review
FileSize
2.01 KB

Needed something like that for a project I'm working on.

Added an alter on the suggestions, to help adding suggestions without having to render them manually, and not rendering suggestions that would be removed.

Also added a matching .api.php file to document this new hook.

janusman’s picture

Status: Needs review » Fixed

Committed! Thanks!

  • DeFr authored 979e153 on 7.x-1.x
    Issue #2157713 by DeFr: Allow autocomplete suggestions to be altered
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.