function hook_search_info

Define a custom search type.

This hook allows a module to tell search.module that it wishes to perform searches on content it defines (custom node types, users, or comments for example) when a site search is performed.

In order for the search to do anything, your module must also implement hook_search_execute(), which is called when someone requests a search on your module's type of content. If you want to have your content indexed in the standard search index, your module should also implement hook_update_index(). If your search type has settings, you can implement hook_search_admin() to add them to the search settings page. You can use hook_form_FORM_ID_alter(), with FORM_ID set to 'search_form', to add fields to the search form (see node_form_search_form_alter() for an example). You can use hook_search_access() to limit access to searching, and hook_search_page() to override how search results are displayed.

Return value

Array with optional keys:

  • 'title': Title for the tab on the search page for this module. Defaults to the module name if not given.
  • 'path': Path component after 'search/' for searching with this module. Defaults to the module name if not given.
  • 'conditions_callback': Name of a callback function that is invoked by search_view() to get an array of additional search conditions to pass to search_data(). For example, a search module may get additional keywords, filters, or modifiers for the search from the query string. Sample callback function: sample_search_conditions_callback().

Related topics

3 functions implement hook_search_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_search_info in drupal/core/modules/node/node.module
Implements hook_search_info().
search_extra_type_search_info in drupal/core/modules/search/tests/modules/search_extra_type/search_extra_type.module
Implements hook_search_info().
user_search_info in drupal/core/modules/user/user.module
Implements hook_search_info().
1 invocation of hook_search_info()
search_get_info in drupal/core/modules/search/search.module
Returns information about available search modules.

File

drupal/core/modules/search/search.api.php, line 45
Hooks provided by the Search module.

Code

function hook_search_info() {
  return array(
    'title' => 'Content',
    'path' => 'node',
    'conditions_callback' => 'sample_search_conditions_callback',
  );
}