Question

I have a content type called "Unit Staff" with a term reference field called "Department". I also have a vocabulary called "Person" which is using a paragraph field consisting of a date field and the same "Department" vocabulary as a term reference. Every department has several child terms. I want to create "Unit Staff" pages where I only select the unit name and a block will display all persons using the taxonomy term.

I have already all page views for every department but if something needs to be changed, I have to go through +30 pages and update them manually. I hope this way to be able to use one view for 30 units/departments.

In other words, I need a view for child taxonomy terms whose parent term is defined in a node taxonomy reference field.

Any help is appreciated.

Was it helpful?

Solution

You actually want to list sibling entities, with another level of complication in between: the paragraph reference.

Both Unit staff and Person reference Department taxonomy, only the Person does it through a paragraph.

Had there been no paragraf and the reference was direct you could simply follow the sibling taxonomy tutorials to get what you want.

Here's an example:
Building views relationship with location

and one with additional complexity:
Views Contextual Filter by taxonomy in field collection

In your case the chained Relationships will be:

Unit staff to Department term reference > Reverse Relationship from Department to Paragraph > Reverse Relationship from Paragraph to Person.

Then you add the Person (Term Name) to your Fields, it will use the last Relationship.

This gives you a list of Unit staff nodes, each with related Persons.

If you want to show a block of Persons on Unit staff pages add the Contextual ID filter for the ID, Default value ID from URL (the most common case). Place the block on Unit staff pages, adjust the contextual options, and the block will show Persons related to the Department of that Unit staff.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top