I'd recommend replacing program field with a custom View of Songs. That will allow you to pull any data that you'd need from the Song content type.
The least cumbersome (and I'd say flexible) way of doing involves two steps:
- Create a View of Songs that will take a Node ID (NID as a contextual filter)
- Override the field template for the Program field and instead of rendering the default template of the field - render a View crated in Step 1.
I'll detail each step, creating a View for this purpose can be somewhat complex, but that will give you great control over how you want to present the information.
STEP 1 - CREATE A VIEW
- Create new View of "
Content
" of the type "Concert
". Select Block instead of Page. Make it a view of "Unformatted List
" of "Fields
". In the number of items put 0
to display all items.
- Add new "
Contextual Filter
" - "Content: NID
". Provide default value: "content ID from URL
"
- Add new Relationship to "
Entity Reference: field_program
", which will give you a connection to each song selected in the filed Program for the particular node. Make relationship required.
- Now remove all default fields that were placed in your View and add fields from the Songs content type (Title and Composer). Select the relationship that you added in previous step to each field (this is important, otherwise View won't work).
- You can test your View by entering a Node Id from any existing Concert nodes into Views Preview placeholder for contextual filters. Without given contextual filter, preview will not show you any results (that's expected)
STEP 2 - OVERRIDE PROGRAM FIELD TEMPLATE
Copy field.tpl.php
from modules/field/theme
and place it into your current theme template folder.
Rename the file. Now here you need to decide if you wish to override the display of the field "Program" everywhere on your website or only when it is displayed in content type Concert.
field--field-name--content-type.tpl.php - Will target a specific field name within a specific content type.
field--field-name.tpl.php - Will target all fields of a specific machine name.
I'd recommend starting with the first choice - field--field-program--concert.tpl.php
Clear cache to let Drupal see your new template.
Now remove everything that was originally in that template, you can leave just the top comments for the sake of maintainability, etc. And add the code below - which will embed the view you create in the STEP 1.
<?php
print views_embed_view('machine_name_of_the_view', 'machine_name_of_the_block', $element['#object']->nid);
?>
$element['#object']->nid
- is an argument that you can to your View. It is not absolutely necessary to place it here, because our View already has contextual filter that takes Content ID from Url
by default. So additional argument just gives another chance to override that argument, or make sure that it will be passed appropriately.
That's it. Give it a whirl. Don't forget to test.