function hook_search_api_autocomplete_types in Search API Autocomplete 7
Inform the module about types of searches for which autocompletion is available.
The implementation has to take care of altering the search form accordingly itself. This should be done by loading the appropriate SearchApiAutocompleteSearch entity and calling its alterElement() method with the textfield element to which autocompletion should be added. See example_form_example_search_form_alter() for an example.
Return value
array An array with search types as the keys, mapped to arrays containing the following entries:
- name: The category name for searches of this type.
- description: A short description of this type (may contain HTML).
- list searches: Callback function that returns a list of all known searches of this type for a given index. See example_list_autocomplete_searches() for the expected function signature.
- create query: Callback function to create a search query for a search of this type and some user input. See example_create_autocomplete_query() for the expected function signature.
- config form: (optional) Callback function for adding a form for type-specific options to a search's autocomplete settings form. See example_autocomplete_config_form() for the expected function signature. This function name will also be the base for custom validation and submit callbacks, with "_validate" or "_submit" appended, respectively.
See also
example_list_autocomplete_searches()
example_create_autocomplete_query()
example_autocomplete_config_form()
example_autocomplete_config_form_validate()
example_autocomplete_config_form_submit()
example_form_example_search_form_alter()
1 function implements hook_search_api_autocomplete_types()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
1 invocation of hook_search_api_autocomplete_types()
- search_api_autocomplete_get_types in ./
search_api_autocomplete.module - Retrieves information about all search types, or a specific one.
File
- ./
search_api_autocomplete.api.php, line 46 - Hooks provided by the Search API autocomplete module.
Code
function hook_search_api_autocomplete_types() {
$types['example'] = array(
'name' => t('Example searches'),
'description' => t('Searches provided by the <em>Example</em> module.'),
'list searches' => 'example_list_autocomplete_searches',
'create query' => 'example_create_autocomplete_query',
'config form' => 'example_autocomplete_config_form',
);
return $types;
}