I have a Drupal 7 project I'm working on that's got me stumped.
I'm building a site where the node (Decals) are applicable to models and years (This decal is correct for this model of this year). Each product my be applicable multiple models and multiple years.

I created a content type that has a field collection of model and years that can have unlimited values. So far so good.

Where i'm stuck is i want to have a related decals block at the bottom, that would suggest additional decals based not the models and years that listed in the field collection.
I've creating a view of nodes that has a relationship to the field collection, but I can't figure out how to limit the results to only the models & years associated to the node.

Any suggestions would be greatly appreciated.

2 Answers 2


To introduce the terms referenced from a field collection field (in your case Model and Year) you first have to add the Relationship to the Field collection field. After that you can add Relationships to the terms referenced from there.

The goal is to list all nodes that share the same terms as the current one. This is usually called "sibling" nodes and is a very common request in Views.

In your case, there is one extra level of structure that the data flows through: the Field collection.

Usually, to display sibling nodes you first add the Relationship to the taxonomy field, then you add the "reverse" Relationship to all the nodes using terms from that field, and you make the second Relationship use the first one. This is where the magic happens, the matching of the current node terms with all the other nodes to find the ones that share the same terms. After that a simple Contextual Content ID is added with Content ID from URL as default value, but it must use the second Relationship.

In your case you will have more Relationships chained because of the Field collection.

F.c.R > Model (term) > Reverse Model (node) > F.c.R

and then add Content ID Contextual filter that uses the last Relationship and set its default value to Content ID from URL.

I haven't tried this myself (I haven't used Field collections with Views) but it seems logical.

If it doesn't work see if these modules help: Taxonomy Entity Index, Taxonomy Deep Index

  • Thanks prkos, that was what I needed to get this solved!
    – jbenjamin
    Jan 21, 2019 at 16:31

Once you have the Relationship to the Field collection, you can add all the other information you need (Relationships to Models and Years if necessary, you'll probably need them too).

Then if you go to add Contextual filters, you will see that Contextual filters for Models and Years fields have become available.

Configure each one to Provide default values from the node you're on (you choose that from the Drop-down under that option).

It's good to test Contextual filters one by one and make sure they work on their own before combining them.

Or in the Views Preview you can test by entering all/[year] to test the second one, or [model]/all to test the first one.

Then place the Block and test that they work in real environment, because Preview only tests the "from URL" part.

  • Thanks prkos, this is where I get stuck though - I've added the relationship (delta - all_. I can add the fields I want to filter into contextual filters, but the default value is what I can't figure out. There are options for content ID (doesn't work), Fixed Value (not useful), Raw Value, PHP code, Taxonomy from URL, User ID from URL, user ID from logged in user. None of these seem to fit the bill
    – jbenjamin
    Jan 17, 2019 at 15:36
  • You don't need delta of the fields, delta is data about the order of multiple values, you don't need that. I'm sorry I didn't give you the proper procedure, I was focused on getting the data into views so you can work with it, but the "sibling" procedure needs some more steps. I'll add a new answer.
    – prkos
    Jan 18, 2019 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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