Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

I have no idea how to do it using views gui but I can tell you how to write your own query which you can use to override the query from views to display it.

All the data you need will be stored in 2 tables

field_data_group_audience.entity_id   // node id of the content you are looking for
field_data_group_audience.bundle      // type of content in your case blog posts

JOIN
node -> type // equal to student group or faculty group

because nid of a group is not the same as gid of a group you have to join the two tables using og table

JOIN
og 
WHERE
og.etid = node.nid
AND
og.gid = field_data_group_audience.group_audiance_gid

This should result in something similar to this:

$query = db_select('field_data_group_audience');
$query->join('og', 'og', 'og.gid = field_data_group_audience.group_audiance_gid'); 
$query->join('node', 'node', 'og.etid = node.nid'); 
$query->addfield('field_data_group_audience','entity_id','tricky_name_expected_by_views');
$query->condition('field_data_group_audience.bundle', blog post,'=');
$query->condition('node.type', 'student group','=');
$view->build_info['query'] = $query;

Once you have a working query you plug it into views using hook_views_pre_execute. http://drupal.stackexchange.com/a/56322/12153https://drupal.stackexchange.com/a/56322/12153

I have no idea how to do it using views gui but I can tell you how to write your own query which you can use to override the query from views to display it.

All the data you need will be stored in 2 tables

field_data_group_audience.entity_id   // node id of the content you are looking for
field_data_group_audience.bundle      // type of content in your case blog posts

JOIN
node -> type // equal to student group or faculty group

because nid of a group is not the same as gid of a group you have to join the two tables using og table

JOIN
og 
WHERE
og.etid = node.nid
AND
og.gid = field_data_group_audience.group_audiance_gid

This should result in something similar to this:

$query = db_select('field_data_group_audience');
$query->join('og', 'og', 'og.gid = field_data_group_audience.group_audiance_gid'); 
$query->join('node', 'node', 'og.etid = node.nid'); 
$query->addfield('field_data_group_audience','entity_id','tricky_name_expected_by_views');
$query->condition('field_data_group_audience.bundle', blog post,'=');
$query->condition('node.type', 'student group','=');
$view->build_info['query'] = $query;

Once you have a working query you plug it into views using hook_views_pre_execute. http://drupal.stackexchange.com/a/56322/12153

I have no idea how to do it using views gui but I can tell you how to write your own query which you can use to override the query from views to display it.

All the data you need will be stored in 2 tables

field_data_group_audience.entity_id   // node id of the content you are looking for
field_data_group_audience.bundle      // type of content in your case blog posts

JOIN
node -> type // equal to student group or faculty group

because nid of a group is not the same as gid of a group you have to join the two tables using og table

JOIN
og 
WHERE
og.etid = node.nid
AND
og.gid = field_data_group_audience.group_audiance_gid

This should result in something similar to this:

$query = db_select('field_data_group_audience');
$query->join('og', 'og', 'og.gid = field_data_group_audience.group_audiance_gid'); 
$query->join('node', 'node', 'og.etid = node.nid'); 
$query->addfield('field_data_group_audience','entity_id','tricky_name_expected_by_views');
$query->condition('field_data_group_audience.bundle', blog post,'=');
$query->condition('node.type', 'student group','=');
$view->build_info['query'] = $query;

Once you have a working query you plug it into views using hook_views_pre_execute. https://drupal.stackexchange.com/a/56322/12153

Source Link
Pawel G
  • 513
  • 5
  • 14

I have no idea how to do it using views gui but I can tell you how to write your own query which you can use to override the query from views to display it.

All the data you need will be stored in 2 tables

field_data_group_audience.entity_id   // node id of the content you are looking for
field_data_group_audience.bundle      // type of content in your case blog posts

JOIN
node -> type // equal to student group or faculty group

because nid of a group is not the same as gid of a group you have to join the two tables using og table

JOIN
og 
WHERE
og.etid = node.nid
AND
og.gid = field_data_group_audience.group_audiance_gid

This should result in something similar to this:

$query = db_select('field_data_group_audience');
$query->join('og', 'og', 'og.gid = field_data_group_audience.group_audiance_gid'); 
$query->join('node', 'node', 'og.etid = node.nid'); 
$query->addfield('field_data_group_audience','entity_id','tricky_name_expected_by_views');
$query->condition('field_data_group_audience.bundle', blog post,'=');
$query->condition('node.type', 'student group','=');
$view->build_info['query'] = $query;

Once you have a working query you plug it into views using hook_views_pre_execute. http://drupal.stackexchange.com/a/56322/12153