My site has 3 nodes:

  • Program, which is a list of Course nodes.
  • Course, which contains basic information about a course you can take
  • Course Date, a specific instance of a Course. Each Course Date references one Course, and the titles are auto-generated.

The view I'm scratching my head over is

  • I need a view that loads on each Program node, showing all current Course Dates who's Entity Reference matches any Course in the current Program.

It would be a lot simpler if each Course was only in one Program, but they aren't.

I've tried Relation and found it too buggy for production. I've tried Reference and Entity Reference, and settled on the latter as it seems more featured.

Would it be possible to automate some kind of reverse field reference? Any tips welcome!

  • Do you need this "I need a view that loads on each Program node, showing all current Course Dates who's Entity Reference matches any Course in the current Program." or this "Would it be possible to automate some kind of reverse field reference?" or both?
    – rooby
    Apr 30, 2013 at 13:32
  • If anyone's interested, I used Boriana's answer along with Draggable Views to make something less extensible but functional!
    – kimadactyl
    Jun 18, 2013 at 10:39

2 Answers 2


Actually Entity Reference does implement reverse pointers, so to speak.

On your program view, which I suppose has entity reference fields to course nodes, first set up a Relationship (under the 'Advanced' view section) that will link to the view the specific Course nodes that exist for the current program as entity references.

  • If you go to add a relationship, you'll get a dialog that looks like this:

enter image description here

  • Set it to filter the potential relationships to ones using 'Entity Reference' fields.
  • Select the 'Referenced entity' field that exists in the Program content type to point to its Courses (whatever you called it). You can choose to change its name to 'Referenced course' or something short like that for later. You can also limit the view to include only Programs that have course fields by checking that 'Require relationship' box!
  • Now all those course nodes are available in your view (you can add their fields to your view if you need to)
  • Next, add one more relationship. This time look for the relationship that is a 'Referencing entity' (as opposed to 'Referenced entity') for your Course Date node. That will provide a link to all Course Date nodes, which themselves reference the current Course node. When setting up this second relationship, make sure you select the previous relationship to be used in the 'Relationship' dropdown. After all, this reverse reference points to the course node of the current program, not to the current program itself, right?
  • Finally, you should now be able to add fields for course nodes and course date nodes that relate to your program, because of these two relationships. Just make sure the fields you add, have the correct Relationship set from the relationship drop-down. That way they will pull from the correct node.

enter image description here

  • Thanks for this, my brain is still fairly confused though! Should the main View be filtering for Programs, Courses or Course Dates? Also the view is on the program node, not the course node. Thanks for the help though, just trying to get my head around the referencing node bridges!
    – kimadactyl
    May 1, 2013 at 13:18
  • Ah, yes, I see. Since this is actually a view of programs that is displaying the 'Program' content types fields, you'd need one extra relationship in there. You'd first need to get the 'Course' relationship set up (as 'Referenced entity') and then add a second relationship that links the Course Date 'Referencing entity' using the already added relationship. I'll edit my response in a few to see if that makes more sense! May 1, 2013 at 14:51
  • Hmm. For now I'm trying to make a Rule to make a reverse node reference for the sake of my poor brain :) will let you know how I get on tomorrow! This solved an unrelated issue I had though :)
    – kimadactyl
    May 1, 2013 at 23:28
  • Which point or step are you having trouble with? I can definitely get a working example working, so I may be able to help. Let me know if there's a specific step in the process that you can't get, and I can provide an extra screenshot or so if needed. :-) May 2, 2013 at 15:34
  • The crux of it is getting the Program into the Course Dates view! I can get the Course to load in as a Referenced Entity, but I can't work out how to get a relationship in from a node that is 2 links away :)
    – kimadactyl
    May 2, 2013 at 20:15

May be you could try (and adapt) this snippet in the contextual filter based on your entity reference field of your view

$ Node = menu_get_object ()   // we get the current node
switch ($ node-> type) {          // We can manage multiple scenarios depending on the type of content
  case 'type A':                          // For the content type A
    $ Related_ids = array ();
    $ Related = field_get_items ('node', $node, 'YOUR_FIELD_ENTITY_REFERENCE')    // Get the entity reference scope
    if ($related && is_array ($related) && sizeof ($related)> 0) {
      for ($i = 0; $i <count ($related); $i++) {
        $ Related_ids [] = $related[$ i]['target_id'];
    return implode ('+', $related_ids) // It returns the values ​​of the field entity reference

    return 0 / / default it returns 0

See this issue for further informations

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.