sample_search_conditions_callback

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 sample_search_conditions_callback($keys)

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

Code

modules/search/search.api.php, line 65

<?php
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 = variable_get('sample_search_force_keywords', '')) {
    $conditions['sample_search_force_keywords'] = $force_keys;
  }
  return $conditions;
}
?>