function sample_search_conditions_callback

An example conditions callback function for search.

This example pulls additional search keywords out of the $_REQUEST variable, (i.e. from the query string of the request). The conditions may also be generated internally - for example based on a module's settings.

See also

hook_search_info()

Related topics

1 string reference to 'sample_search_conditions_callback'
hook_search_info in drupal/core/modules/search/search.api.php
Define a custom search type.

File

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

Code

function sample_search_conditions_callback($keys) {
  $conditions = array();
  if (!empty($_REQUEST['keys'])) {
    $conditions['keys'] = $_REQUEST['keys'];
  }
  if (!empty($_REQUEST['sample_search_keys'])) {
    $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys'];
  }
  if ($force_keys = config('sample_search.settings')
    ->get('force_keywords')) {
    $conditions['sample_search_force_keywords'] = $force_keys;
  }
  return $conditions;
}