You are here

function theme_finder_autocomplete_suggestion in Finder 7

Same name and namespace in other branches
  1. 6 modules/finder_autocomplete/finder_autocomplete.module \theme_finder_autocomplete_suggestion()

Theme an autocomplete popup suggestion.

This is a very useful theme function as it lets you pretty much display any sort of HTML you want. By default the CSS styles will be really ugly, but with a bit of work you can really make this do something special. For example - if your autocomplete searches for a value that is unique to different nodes (like a node title or sku perhaps) you can assume that each match corresponds to a node. If you debug the $option and $element variables, you will see that you have enough data there to node_load() or user_load() a full object, and display it any way you like, such as teasers (using the node_view() function). You can even have pictures and links in the HTML! Even if you don't expect unique nodes/users/etc.. there is still a lot of potential for adding stylized output here. Here is some CSS to get you started on styling something like a node teaser in an autocomplete popup suggestion. Note that this CSS is very general and may affect other forms on your site - take care to add more specific selectors. <code> <style type='text/css'> #autocomplete li.selected { background: #eee; color: inherit; } #autocomplete li { white-space: normal; margin: 0; } #autocomplete ul.links, #autocomplete ul.links li { background: none; } #autocomplete p { margin: 0; } </style> </code>

Parameters

$variables: 'option' - The result data. 'finder_element' - The finder element object.

1 theme call to theme_finder_autocomplete_suggestion()
finder_autocomplete_autocomplete in modules/finder_autocomplete/finder_autocomplete.module
Menu callback; get autocomplete suggestions.

File

modules/finder_autocomplete/finder_autocomplete.module, line 277
The finder autocomplete module.

Code

function theme_finder_autocomplete_suggestion($variables) {
  $option =& $variables['option'];
  return $option->{$option->display_field};
}