After many days of unraveling views, entity references, and paragraphs, I finally figured this out. The moment was celebrated with an awkward, club-footed jig.
For context, I'm building a financial data delivery site that connects investment fund managers with funds to manage. My content types look like this:
I have an entity type called Contact, which has inside it a Paragraph field called Job History. There are 3 different job history paragraph bundles for 3 different types of jobs, but each type has fields for Job Title, Phone, Email, Employment Date, and an entity reference field called Fund. I also have another entity type called Fund, which is referenced by the Fund reference field.
1. Contact (entity)
- Job History (paragraph)
-- Fund
-- Job Title
-- Phone
-- Email
-- Employment Date
2. Fund (entity)
- Various fields (irrelevant to this solution)
I want to create a table view that will appear on all Fund pages, and show any contacts, with their contact info, for said Fund. In other words, this view should display any Contact nodes that reference the current Fund node, along with those nodes' phone, email, etc fields. I can achieve this using only Views...
- Create a content view and filter by node type: Contact.
- Add a relationship, Content: Field (Job History). This allows me to access the fields inside the Job History paragraph field.
- Add all above fields I want to display (name (title), job title, phone, &
email) to the Fields section, making sure each one uses the Paragraph item from field_job_history relationship.
At this point, I have a view that displays all contact nodes & their fields. Let's narrow it down to those that reference only the current Fund node.
- Add a relationship, Entity Reference: Referenced Entity (A bridge to the Content entity that is referenced via field_reference_fund). Use the existing relationship, Paragraph item from field_job_history.
- Add a contextual filter for Content: NID. Use relationship, Content entity referenced from field_reference_fund. Provide default value: Content ID from URL.
The view will now display the fields within the paragraph, and limit the results to only those nodes that reference the current node.
I hope this provides the solution you were looking for!