2

CONTEXT: Let's say I have a one-to-many relationship between parent "companies" and child "contacts". Each is its own content type. The contacts content type has a field of type Entity Reference that can be used to associate a child Contact node to a parent Company.

QUESTION: How, when I am on the display of an individual Company node, can I see a list of related contacts right beneath the Company node fields?

Essentially this functionality would be like a "related list" in Salesforce.

Surely there is a module or modules that enable this without having to resort to code?

I've seen the Views Field View module. It looks promising. The Panels module looks promising but apparently it is not just for use on its own; it just enables other modules.

2
  • As a block display on the node page you just use Views that take node id as contextual filter and a relationship to the contacts type. As part of the actual node display you can use Display Suite and embed similar view as an added on 'field' Commented Jan 27, 2016 at 7:01
  • +1 @J.Reynolds for referring me to the Display Suite which has a production release for Drupal8 and also has a very large number of reported installs. Thank you!
    – Jon Freed
    Commented Jan 28, 2016 at 16:39

4 Answers 4

3

Thanks in part to @Niall Murphy's response, I was able to find a Drupal Community Doc that got me further along, though I had to do some translation from Drupal-7 terminology to Drupal-8 terminology before I reached a solution/answer. I've updated the Doc accordingly so you can read it for the solution/answer details.

Note: No additional modules were needed. I was able to do everything with freshly-installed out-of-the-box Drupal 8.0.2 functionality.

0
2

In your view, for RELATIONSHIP, click add and select referenced entity. If not try Referencing entity, but I am confident that it's referenced.

1
  • Thank you, but it looks you're starting from the view, and I want to start from the display of an individual parent company node. I've edited my question to help clarify that point.
    – Jon Freed
    Commented Jan 28, 2016 at 16:31
2

In your relationships for views, there are two options per entity reference. Check those.. I believe they're called referenced by and referencing.

3
  • Thank you, but it looks you're starting from the view, and I want to start from the display of an individual parent company node. I've edited my question to help clarify that point.
    – Jon Freed
    Commented Jan 28, 2016 at 16:32
  • You have to create a block from the view and display the block on the company nodes.. Can help further tomorrow if needed. Commented Jan 28, 2016 at 16:37
  • Thank you, @Niall Murphy. Your words led me to a Community Doc. After I translated its Drupal-7 terminology to Drupal-8 terminology I was able to achieve what I wanted. I updated that Doc to help others.
    – Jon Freed
    Commented Jan 28, 2016 at 22:50
1

As EVA: Entity Views Attachment doesn't have Drupal 8 version, you can use the Display fields module.

This module provide display field types used only in "display" mode.

The UI are located in the entity type: display settings form additional settings tabs. The display fields are build and cached within the entity content like the regular fields. The weight and display settings are set on the entity display settings form like the regular fields.

Features

  • Embed a view, set the display, provide values for arguments from the context (the entity being displayed). Example: list of blog post for a homepage of a blog.

So, you can make a View with the "parent" nid as argument and load all its childs, then embed this View in the node display.

5
  • Thank you. This is helpful. But the "Display fields" module has such a low number of reported installs (8) that I question why it would be better than another module, like Views Field View or the Display Suite module that J.Reynolds referred me to (through a comment on the question)
    – Jon Freed
    Commented Jan 28, 2016 at 16:42
  • @JonFreed When you solve the problem please write here your solution to learn from it. Commented Jan 28, 2016 at 16:46
  • @JonFreed take in count that Display Suite have his numbers because it works in D6 and D7, and D8 is new, good luck solving your problem. Commented Jan 28, 2016 at 16:48
  • Thanks, @Adrian Cid Almaguer. I have updated the question with solution/answer details.
    – Jon Freed
    Commented Jan 28, 2016 at 23:11
  • @JonFreed post the solution has an answer, you can do it, and it is ok Commented Jan 28, 2016 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.