I have 2 different node types. The first one describes a factory and the second one describes a measurement of the water inside the factory. The measurement content type has an Entity Reference field that points to the factory that the measurement is associated with.
What I want to do is print a list of all the factories in a table format and a specific column that will contain a field from the latest measurement that relates to the specific factory.
For example:
Factory 1
field 1
field 2
field 3
Factory 2
field 1
field 2
field 3
Measurement 1
Refers to Factory 1
Integer Field
Date Created: 21/5/2013
Measurement 2
Refers to Factory 1
Integer Field
Date Created: 22/5/2013
Measurement 3
Refers to Factory 2
Integer Field
Date Created: 10/2/2012
Measurement 4
Refers to Factory 1
Integer Field
Date Created: 23/5/2013
What I want to print:
Factory 1 || field 1 || field 2 || field 3 || Integer Field (from Measurement 4)
Factory 2 || field 1 || field 2 || field 3 || Integer Field (from Measurement 3)
Notice that I'm only printing the Integer field from Measurement 4 since it is the latest measurement for the specific factory. I started writing some custom code and looked into EntityFieldQuery but I can't understand how to use it in conjunction with Entity Reference.