Skip Navigation

[Resolved] How to display deduplicated list of parents of children of parents of children

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.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Brad 4 years, 10 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#343809

Following the article at https://toolset.com/documentation/user-guides/many-to-many-post-relationship/ I have created the following structure successfully and am able to create, edit, and delete but am having trouble building View(s) to display:

Primary custom post types: Officers, Units, Areas (These are Parent CPTs.)
Intermediary object custom post types: Assignments, Deployments (These are Child CPTs.)

Assignments are children of Officers and Units.
Deployments are children of Units and Areas.

Conceptually, Officers are assigned to Units are deployed to Areas.

I want to create a View (or Views) that will display a deduplicated list of all Officers who are assigned to all Units that are deployed to the Area that is the current post. (If an Officer is assigned to more than one Unit that is deployed to the Area, I want to display the Officer only once, not once per Unit.) In more general terms, this would be how to display a deduplicated list of parents of children of parents of children of the current post.

How can I most efficiently accomplish this?

#344001

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Brad,

I assume you have already setup the nested view, but you need to be able to remove the duplicated Officers posts.
I suggest you try Views filter hook wpv_filter_query_post_process, to remove the duplicate items:
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query_post_process/

#344190

Thanks, Luoy, but I'm still stuck on getting the nested views right. Can you tell from the attached screenshots where I'm going wrong?

The hierarchy of Views and Templates is as follows:
AreaTemplate4
-UnitAreaView4
--UnitListTemplate4
---OfficerListView4
----OfficerListTemplate4

Thanks.

Brad

#344226

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Could you setup a test site, and fill below private detail box with login details, I need test and debug in a live website, thanks

#344469

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I tried log into your website, but get this error message:
Your access to this site has been limited

Your access to this service has been temporarily limited. Please try again in a few minutes. (HTTP response code 503)

Please check it. thanks

#344470

Sorry, I forgot that Wordfence was configured to block non-US addresses.

Please use hidden link to access the site. That should set a cookie and then redirect you to hidden link. From there you should be able to log in normally.

Brad

#344509

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Brad,

Thanks for the details,
1) The post type relationships does not same as you described above:
Assignments are children of Officers and Units.
https://toolset.com/forums/topic/how-to-display-deduplicated-list-of-parents-of-children-of-parents-of-children/#post-343809
See it in your website:
hidden link
Post type "Officers" is child post type of "Units"

2) I have made below modification in your website:
a) edit the test post "Little Italy":
hidden link
Remove all codes in content, in the sidebar, section "Content Template", choose option "AreaTemplate4"

b) modify the top level view "UnitAreaView4",
hidden link
in section "Loop Output", use below codes insider wpv-loop:
[wpv-post-body view_template="UnitListTemplate4" id="$units"]
It should be able to display the information from parent units post

c) modify the second level view "OfficerListView4":
hidden link
in section "Query Filter", setup it as:
Select posts that are a children of the Post set by parent View.

And I did not see duplicated items. Please test again, and I did not see duplicated items, check if it is fixed or not, thanks

#344760

Luo, that is exactly what I was trying to do. Thank you so much for your explanation!

I will be away from my office today but tonight I plan to go through each of the steps you described to make sure I understand correctly your explanation. I'm sure I will use this concept many times once I understand the details properly.

You have my sincere thanks and appreciation.

Brad