2

I have 3 content types A, B, C. B and C have entity reference fields that reference to A and B and with different machine names. I want to get the parent node ID from referenced node.

A is referenced to B B is referenced to C

Now if I am on A then I want to get B node id and if I am on B then I want to get C node id.

How can I achieve this programatically.

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398

1 Answers1

0

You could do this with the Corresponding Entity References module, which can create a two-way reference when a single reference is set. That way it prevents having to search for the parent.

Otherwise, you can use Views, which can search for the parent via Relationships.

firewaller
  • 426
  • 2
  • 8