ICT:D Asset-Chain header arrangement with top asset
Drupal 11: Displaying Parent Asset Metadata in a Recursive View Header
This guide explains how to display fields (Thumbnail, Caption) from a parent "Digital Asset" entity in the header of a View that lists its children.
Prerequisites
Content Type: Digital Asset (containing fields: Template:code, Template:code). Entity Reference: A field (e.g., Template:code) linking children to parents. Main View: An existing View (e.g., AssetChain) showing child assets in a table.
Step 1: Create the "Header" Block Display
Instead of a new View, we add a specialized display to the existing one. Open your AssetChain View. Click + Add and select Block. Crucial: Change the "Display name" to "Parent Header Block". In the center column, look for the dropdown that says "All displays" and change it to This block (override). Fields:
- Add Template:code.
- Add Template:code.
- Remove any fields you don't want in the header (like the table columns).
Pager: Set to "Display a specified number of items" and set value to 1. Contextual Filter:
- Add Template:code (from the Content category).
- Set "When the filter value is NOT available" to Hide view.
Save the View.
Step 2: Format the Header Layout (Optional but Recommended)
To make the thumbnail and caption sit side-by-side: In the Parent Header Block display, add a Global: Custom text field. Move it to the bottom of the field list. Mark the original Thumbnail and Caption fields as Exclude from display. In the "Custom text" box, use the following HTML (adjust tokens based on "Replacement Patterns"):
Template:field media thumbnail
Parent Asset Template:field asset caption
Step 3: Embed the Block in the Main View Header
Switch back to your Main View (the Page or Block that shows the table). In the Header section, click Add. Search for and select Global: View area. Configure the View Area:
- View to insert: Select "AssetChain".
- Display to insert: Select "Parent Header Block".
- Inherit contextual filters: File:Checked checkbox.png CHECK THIS BOX. (This passes the Parent ID from the URL to the header).
Click Apply and Save the View.
Troubleshooting
Empty Header: If the header doesn't appear, check that the "Inherit contextual filters" box is checked in the View Area settings. Wrong Asset: Ensure the Contextual Filter in the "Parent Header Block" is targeting the ID of the asset, not the reference field.