7

I have three content types: compositions, recordings and artists. Compositions have entity references to artists for the field composer. Recordings have entity references to compositions for the field composer and to artists for the field recording artist. This is what I want to do:

  1. I would like to display a page with a list of all the compositions and their composer (entity reference to Artist content type). No problem here.
  2. I would like another field with the field recording artist (an entity reference field in content type Recording) that is being referenced by an entity reference for the content type composition. This is the problem.

I think the main problem is I'm trying to call a field from an entity reference's entity reference. Is there a way to build that bridge?

1

You can use custom Displays to daisy-chain entity reference fields in this fashion (unless I misunderstand your requirements).

To do this...

  1. Install the Entity View Mode module.
  2. Then in configuration - system - entity view modes, create a new display for the entity in question and make sure it is attached to the recording type. Give your new display a self-explanatory name such as "embedded recording" to avoid confusion later.
  3. Next, go to your recording entity's display mode settings, (eg 'manage display') and in the new "embedded recording" display make sure the Recording Artist entity reference field is visible.
  4. Finally, go to your Composition entity's display mode settings (its 'manage display'), and for the Recording entity reference field, choose rendered entity as its format and pick "embedded recording" as its view mode (this option becomes available if you click on the little gear icon on the right hand side).

(Of course this would be far easier if you could add new display modes from the manage display setting! One day perhaps...)

0

I recently spent a lot of time on a very similar problem, so your question caught my eye. Note I'm new to Drupal, so take everything below with a good grain of salt.

If I understood correctly, you want the following architecture: Composition references Recording. Recording references Artist (let's call this Recording Artist).
And you want the following functionality. Firstly, you want to access the Recording Artist fields (e.g. name), given the Composition entity. Secondly, you want to add Recording Artist fields to the Composition entities' content object, so it could be printed out by templates along with other Composition fields. In other words, you want to make the Recording Artist fields accessible through the Composition entities' content object.

Consult this very nice answer by juhog. I believe it relates very well to what you're trying to do. It explains how to 'gain access to referenced entities' and how to append fields from referenced entities to referencing entities.

With this I was trying to nudge you in the right direction, because your question seemed confused (you have my sympathy, I've been there). I have limited experience so I will refrain from giving coding examples.

0

You just need to add a relationship of the third content type in the view and use a field of that content type in your field list, it will pick it up because when you add a relationship views will add a join statement in your sql query and you can use the columns of that joined table in your output.

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.