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.

  • Le me get this right you want your articles to be part of a collection right? – Mohammed Shameem Jan 25 '13 at 15:25
  • Yes, and while adding collection you can also specify the articles to be in the collection. – Kalpesh Patel Jan 25 '13 at 15:26
  • and you are using the entity reference field I suppose. – Mohammed Shameem Jan 25 '13 at 15:33
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.

  • It is not working. It is listing all articles having collection. – Kalpesh Patel Jan 28 '13 at 4:19
  • could you show me a screenshot of the view you have created. – Mohammed Shameem Jan 28 '13 at 4:20
  • sure please give me some time. – Kalpesh Patel Jan 28 '13 at 4:21
  • Please go to: i47.tinypic.com/2d7g08n.jpg – Kalpesh Patel Jan 28 '13 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. – Mohammed Shameem Jan 28 '13 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.

-1

millionleaves, did you succeed? In my approach i have "other answers" for the same question, but on the all answers pages the block is the same.

The reletionships are: Entity Reference: Question (Content entity referenced from field_question) Entity Reference: Referencing entity

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.