Question

I'm running Drupal 7 with Entity Reference and Organic Groups. I have two content types, one of which is a group and the other is group content. I have an Entity Reference field (Select List) that references group content associated with the group.

I want to create a View that ONLY shows the value of the field that is selected from this Entity Reference field in the group content type.

For instance:

 Team: Red Sox
 Location: Fenway

Location is a content type (group content) and Team is the group. There are many teams and many locations but when I'm looking at the group page I want a View that ONLY shows a single location (the one SELECTED in the group content type).

Was it helpful?

Solution

After much research I realized that Views and context can't handle this on their own. I ended up using View PHP to construct a filter that effectively filtered out all OTHER results than the one that I wanted:

$node = menu_get_object();
$item = field_get_items('node', $node, 'field_name');
$loc = $item[0]['target_id'];
$refnode = node_load($loc);
$primary = $refnode->title;
if ($primary != $row->title) {
  return TRUE;
}

You're welcome for this one :) If anybody has any better suggestions on how to code this feel free to comment or post alternate solutions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top