A simple 'reverse node reference' Views so you can show a block on a node and show items that reference it

The European Greens (and other clients since) wanted to have blocks showing News items relating to their Party pages, so that for example a news item that 'node references' Die Grunen would show up on the page about Die Grunen.

The concept is simple enough and can be handled in Views but requires a bit of extra configuration.

For its usage on this site for example, this blog is 'related' to the European Greens (client). So on the Client 'content type' you need a 'node reference' field. And on this blog there is a field where I can use an autocomplete to find European Greens.

Then there is a block that is set to show just on Client content types, and that View has:

  • a Contextual Filter to check the node id that is being viewed,
  • a Relationship ((node reference) (field_<fieldname>) - reverse) to return the nodes that reference the one being viewed.

 

Requires Reference and Node Reference as well as Views of course.

The attached View should work though you may need to tweak the field name for the node reference.

Hat Tip to CodeForbidden for the clear write up on this.

NB to import a View in D7 you either need to be user/1 or to Masquerade as admin.