function viewfield_views_query_alter in Viewfield 6
Same name and namespace in other branches
- 5 viewfield.module \viewfield_views_query_alter()
 
Implementation of hook_views_query_alter().
Prevent views from loading the node containing the view.
File
- includes/
viewfield.views.inc, line 13  - Views functions.
 
Code
function viewfield_views_query_alter(&$view, &$query) {
  global $_viewfield_stack;
  if (!empty($_viewfield_stack) && in_array('node', $query->table_queue)) {
    $placeholders = db_placeholders($_viewfield_stack);
    $query
      ->add_where(0, "node.nid NOT IN ({$placeholders})", $_viewfield_stack);
  }
}