function hook_views_query_alter


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 views.api.php hook_views_query_alter(&$view, &$query)
cle7 views.api.php hook_views_query_alter(&$view, &$query)
elmsmedia7 views.api.php hook_views_query_alter(&$view, &$query)
icor7 views.api.php hook_views_query_alter(&$view, &$query)
meedjum_blog7 views.api.php hook_views_query_alter(&$view, &$query)
mooc7 views.api.php hook_views_query_alter(&$view, &$query)

Alter the query before executing the query.

This hook should be placed in and it will be auto-loaded. must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified.


$view: The view object about to be processed.

$query: An object describing the query.

See also


Related topics

1 function implements hook_views_query_alter()

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

node_reference_highlight_glossary_views_query_alter in sites/all/modules/elmsln_contrib/nodereference_highlight/features/node_reference_highlight_glossary/
Implementation of hook_views_query_alter().
1 invocation of hook_views_query_alter()
views_plugin_query_default::alter in sites/all/modules/ulmus/views/plugins/
Let modules modify the query just prior to finalizing it.


sites/all/modules/ulmus/views/views.api.php, line 996
Describe hooks provided by the Views module.


function hook_views_query_alter(&$view, &$query) {
  // (Example assuming a view with an exposed filter on node title.)
  // If the input for the title filter is a positive integer, filter against
  // node ID instead of node title.
  if ($view->name == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) {
    // Traverse through the 'where' part of the query.
    foreach ($query->where as &$condition_group) {
      foreach ($condition_group['conditions'] as &$condition) {
        // If this is the part of the query filtering on title, chang the
        // condition to filter on node ID.
        if ($condition['field'] == 'node.title') {
          $condition = array(
            'field' => 'node.nid',
            'value' => $view->exposed_raw_input['title'],
            'operator' => '=',