1

I have a 2 content types.

  1. Article
  2. Page

and the Article content type can reference pages from an entity reference field.

Now I want to display a block on Article nodes that have a same reference.

So I tried this:

  1. Create a views block listing Articles.
  2. Add some fields.
  3. Add a relationship field_page_reference: Content
  4. Add contexual filters of Content Id and provide default value to Content Id From URl and Specify validation criteria set to Content and select article.

But it doesn't work? Any idea?

0

You're on the right track, but you're missing another Relationship.

You've added the Relationship that points to a referenced Page. Now you can show that Page info in your views, but that isn't what you want. You want to show all other articles that reference that page (siblings).

To do that you need to add another Relationship that goes in reverse, from Page back to article: Content using field_page_reference and make it use the first Relationship (this is where the matching is happening!).

Then modify your ID Contextual filter to use the second Relationship.

Now you'll have a list of all articles that reference the page that is referenced on the article you're currently viewing.


That includes the current article BTW, so if you want to exclude it from the list you have to add another ID Contextual filter "Content Id From URl" but don't use any Relationships and under More select Exclude.

  • Thanks a million, it worked like charm, is this correct if I want to show articles block that reference to into page content type ? – fox Mar 2 at 20:33
  • I mean what should i do if I want to display related articles into page content type? – fox Mar 2 at 20:34
  • Currently, I'm able to show articles with the same reference now I want to display articles related to a page on the page – fox Mar 2 at 20:51
  • Thanks found the answer : sandstormdesign.com/blog/… – fox Mar 2 at 21:29
  • As you already found, the configuration is a bit different, to show a block of Articles that reference a Page use the "Pulling fields of “Child” nodes by node reference:" part of that article. – prkos Mar 2 at 22:00

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.