phpdrupaldrupal-7drupal-viewsentityreference

How can I eliminate duplicate Drupal nodes in a View when one CT references the other?


Drupal 7 with relevant Modules: Views & Entity Reference

I have a view that simply shows the "Teaser" display type of two different Content Type records, we'll say they are Article and Page.

My Article CT has some simple fields that are shown.

My Page CT has a few fields, but also an Entity Reference field (unlimited entries). The Entity Reference field points to other Article nodes.

My View then, as expected, shows each record's Teaser display and of course when a Page record references another Article record, that Article's teaser is shown as part of the Page teaser.

This is great. The problem is, I do not want to show duplicate Article teasers. That means, if a Page references an Article, I don't want to show that same Article teaser as an individual listing.

Think of it like this, I have these Articles:

  1. Article 1
  2. Article 2
  3. Article 3

And I have these Pages:

  1. Page 4
  2. Page 5
  3. Page 6

Page 4 points -> at Article 1 and Article 2

Page 6 points -> at Article 2

TL;DR

Right now the view would show something like:

What I want is this:

EDIT: Here's a quick diagram of what I'm trying to do. This is using "Content" instead of "Fields" for the View by the way, since there's unequal fields in the View of the two CTs.

Diagram


Solution

  • I ended up knocking this out by making use of the Corresponding Entity Reference module (CER). This creates a 2-way relationship that is sync'd between the parent<->child. Using that, I could simply filter all children which have a parent from the View.