1

I'm getting a little confused trying to get this one, thought I'd get some help.

I have two content types (A and B) both with the same list field (My List). I want to include a view in content type A that finds all nodes of content type B with the same My List value.

I've looked through Context, Entity Reference (which I didn't really get) and Views Relationships and Contexts but couldn't make much sense of it.

What's the best way to accomplish this?

Edit:

I've added an image of my desired output (from actual site) and the current fields of content type's A and B.

An important note is that the Views block/whatever showing content type B needs to be shown in the normal node page of content type A.

I know this isn't the best way to do this, but this feature wasn't planned and the client just wants it to work as fast as possible

Content Types Fields:

I've excluded irrelevant fields such as path and meta tags.

Content type A:

Title - text
Body - HTML (w/ text inside)
Department - List

Content type B:

Title (name) - text
Description - text
Department - List

Desired Output:

Desired Output

3
  • What is for you a view in content type A? and can you provide a Image of your desire output? Commented Dec 8, 2015 at 5:10
  • Yes, I'll add it right now.
    – Neta
    Commented Dec 8, 2015 at 9:21
  • You can achieve this with my answer, takes a look and let me know the result Commented Dec 8, 2015 at 14:28

1 Answer 1

2

Create a View to show nodes of Content Type B, add a Contextual Filter for your field My List and save the view.

Install the Views Field View module and then in the Footer region of your View of Content Type A add the Global: View (Views field view) and configure under the View settings the Name and Display of your B View and the token for the Contextual filters.

To use the value of the My List field as a token, you must have in the Fields of your view this field selected.

Edit after your comment ("I'd prefer to keep using the regular node page.")

You can use the EVA module, it provides a Views display plugin that allows the output of a View to be attached to the content of any Drupal entity, in your case the node of Type A. In the contextual filter of the view you need select the My List field in the Entity Content Settings of the View using a token.

"Entity Views Attach: Use Views Almost Anywhere" contains a great tutorial about it.

4
  • Content type A isn't shown using a view, and I'd prefer to keep using the regular node page.
    – Neta
    Commented Dec 8, 2015 at 15:06
  • @neta give a minute Commented Dec 8, 2015 at 15:07
  • @Neta sorry for the delay, I edit with the oter option ;-) Commented Dec 9, 2015 at 4:36
  • 1
    Thanks! That was extremely helpful and exactly the way I wanted it to be! Add to your answer that I also needed to add an argument to My List field in the Entity Content Settings in the view using a token.
    – Neta
    Commented Dec 9, 2015 at 12:51

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.