1

I have two content types. "Article" and "Collection". Any article can be placed into collection. Also when you create collection, you can select articles to be placed into collection. So I have created "collection" as node reference field in "Article" content type, and "article" as node reference field in "Collection" datatype.

Now when I am on any article page, I want to create view that shows other articles from the same collection. I have tried adding "collection" as relationship and contextual filter as "NId" with relationship with "collection", but it is listing all articles that is having any collection(may reference to other collection) and not the articles that belongs to collection of current article.

Am I doing something wrong?

Please suggest.

-- Thanks for your time.

3
  • Le me get this right you want your articles to be part of a collection right? Commented Jan 25, 2013 at 15:25
  • Yes, and while adding collection you can also specify the articles to be in the collection. Commented Jan 25, 2013 at 15:26
  • and you are using the entity reference field I suppose. Commented Jan 25, 2013 at 15:33

2 Answers 2

2

Let us assume the the filed in collection that referes to article is field_entity_article

Then you would do the following.

  1. With in your view first you would add a relationship called Entity Reference: Referenced Entity (A bridge to the Content entity that is referenced via field_entity_article)
  2. The you would add another relationship Entity Reference: Referenced Entity (A bridge to the Content entity that is referenced via field_node_article) While you are here select the previous relationship you created from the dropdown Relationship
  3. Add a contextual filter of the type content: nid and provide default argument and select node id from url form the dropdown.
  4. Add the required field and give the second relationship we created for this.

That should do it.

22
  • It is not working. It is listing all articles having collection. Commented Jan 28, 2013 at 4:19
  • could you show me a screenshot of the view you have created. Commented Jan 28, 2013 at 4:20
  • sure please give me some time. Commented Jan 28, 2013 at 4:21
  • Please go to: i47.tinypic.com/2d7g08n.jpg Commented Jan 28, 2013 at 4:32
  • I dont think you have tried the method I mentioned in my post. there would be two relationships. there will not be any relationship for the contextual filter as such. Commented Jan 28, 2013 at 4:35
0

I used the same approach as Mohammed, but found that the second Contextual Filter needed to be the Referencing Entity, not the Referenced Entity.

In essence, the first relationship identifies the Collection the current node is referencing. The second relationship uses the first relationship to identify any nodes where the Collection reference is the same as the current node.

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.