You are here

function theme_apachesolr_autocomplete_highlight in Apache Solr Autocomplete 7.2

Same name and namespace in other branches
  1. 6 apachesolr_autocomplete.module \theme_apachesolr_autocomplete_highlight()
  2. 7 apachesolr_autocomplete.module \theme_apachesolr_autocomplete_highlight()

Themes each returned suggestion. TODO: Move theming functions into JS.

File

./apachesolr_autocomplete.module, line 258
Alters search forms to suggest terms using Apache Solr using AJAX.

Code

function theme_apachesolr_autocomplete_highlight($variables) {
  static $first = TRUE;
  $html = '';
  $html .= '<div class="apachesolr_autocomplete suggestion">';
  $html .= '<strong>' . drupal_substr($variables['suggestion'], 0, strlen($variables['keys'])) . '</strong>' . drupal_substr($variables['suggestion'], strlen($variables['keys']));
  $html .= '</div>';
  if ($variables['count'] && $variables['show_counts']) {
    if ($first) {
      $html .= "<div class='apachesolr_autocomplete message' style='float:right'>";
      $html .= t('!count results', array(
        '!count' => $variables['count'],
      ));
      $html .= "</div><br style='clear:both'>";
      $first = false;
    }
    else {
      $html .= "<div class='apachesolr_autocomplete message count'>" . $variables['count'] . "</div><br style='clear:both'>";
    }
  }
  return $html;
}