Skip Navigation

[Resolved] Displaying grandchild information on grandparent page with many-to many

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by glenn 3 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1859229
Capture2.JPG
Capture1.JPG

Tell us what you are trying to do?
Displaying grandchild information on grandparent page with many-to many relationship.

The setup is as follows:
Projects is the grandparent
Partners is the child
Reports are the grandchild

All these post types are many to many relationships. I have created a view that is displayed on the project page(parent). This view lists the related partners. In this view i have created a nested view that displays the reports of the partners.

However the problem is that it shows all the reports of that partner(so also reports from other projects). I need to filter this view so it will only display the reports that belong to the current grandparent.

Is there any documentation that you are following?
https://toolset.com/forums/topic/display-children-at-grandparent-level/

Is there a similar example that we can see?
I included two screenshots of the view on two different projects.

What is the link to your site?
It is still on localhost.

#1859483

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Glenn,

Thank you for getting in touch. Without seeing the filters I won't be able to see what you've done so far.

Currently I know that you will need to 2 views. 1 for the Parent and 1 for the child.

You will add a filter on the Parent view to Filter based on It's Parent i.e the GrandParent.

Secondly you will need to add a filter to the child view for it's Parent.

Once this is done you nest the Child view In the Parent and the Parent view Inside the grandparent content template.

If you can send me a couple screenshots of the Relationship filters on the views then I can see what is happening.

Thanks,
Shane

#1862825
screen 5.jpg
screen3.jpg
screen4.jpg

Hi Shane,

thank you for your reply. I have included screens from the views setup.

I think i know where the problem is. The system does not know which report belongs to which project. So if i show the partners and the reports that belong to them it shows all the projects of that partner instead of only the ones that belong to that project.

Can i pass the project id to the form that inputs the reports automatically. (So when your in a project you click a button with a url parameter that links to a cred form to add new a new report. See screen 5)

#1862863

I actually managed to pass the parameter. But i am now facing another issue. I need to be able to filter the view based on these two relationships. So the view needs to only show reports that belong to Project X and Partner Y.

How can i do this, i can only filter on one relationship.

#1862969

Hi, Shane is on vacation this week so I'm looking in on his outstanding tickets.

I need to be able to filter the view based on these two relationships. So the view needs to only show reports that belong to Project X and Partner Y.
If I understand correctly, you have a View of Partners that is displayed on the post for Project X. That View of Partners is filtered by the Project - Partner M2M relationship, so that only Partners related to the current Project are displayed. Nested inside that View of Partners is another view of Reports. That View of Reports is filtered by the Partner - Report M2M relationship, so that only Reports related to the current Partner are being displayed. However, the problem is this View of Reports shows some Reports that are related to the current Partner, but since that Partner can be related to multiple Projects, so some of the Reports are not necessarily related to the current Project.

Is that correct?

If so, how are Reports and Projects related? Is there a M2M relationship between them directly, or is there an implied, indirect association through Partners? If it's an implied, indirect association through partners, there's not really a simple solution in this case because there is no way to determine which Project-Partner relationship is the ancestor of a specific Report. It is not a true hierarchical grandparent > parent > child setup, because each parent Partner can have multiple parent Projects which are all unrelated to the Reports. In other words, the Report's grandparent cannot be determined in this setup because each Partner can belong to multiple Projects, and the association between an individual Partner and an individual Report is not related to a specific Project - Partner relationship, only to a specific Partner. Each Partner-Report relationship exists independently of each Project-Partner relationship, with no link or hierarchy between these two M2M relationships.

#1873403

My issue is resolved now. Thank you!