Skip to content

Instantly share code, notes, and snippets.

@kitikonti
Created March 15, 2017 17:49
Show Gist options
  • Save kitikonti/304dee044654118e0180f917b5f44a50 to your computer and use it in GitHub Desktop.
Save kitikonti/304dee044654118e0180f917b5f44a50 to your computer and use it in GitHub Desktop.
view connect table
/**
* Implements hook_views_query_alter().
*/
function mh_search_wish_views_query_alter(&$view, &$query) {
if ($view->name == 'matching_search_clients') {
$join = new views_join();
$join->table = 'search_wish_hit_status';
$join->field = 'profile_nid';
$join->left_table = 'node';
$join->left_field = 'nid';
$join->type = 'left';
$query->add_relationship('hit_status_relation', $join, 'node');
$query->add_where(0, 'hit_status', 'offered', '=');
// if i do the add field here my view displays now results
// $query->add_field('search_wish_hit_status', 'hit_status', 'Hit status');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment