Skip Navigation

[Resolved] Displaying multiple Parent's addresses on a map using a child view

This support ticket is created 3 years, 8 months 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 16 replies, has 3 voices.

Last updated by Jamal 3 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1736035

Perfect. I want to do exactly what you said:

"If you would like to display the Rallies from Parks that have rating 4, you will need to create a view to query Parks based on the rating, then you can use a nested view inside its loop. The nested view needs to be filtered by the relationship to the current post in the loop."

Do you have an example of this nested view?

Gary

#1736291

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Awesome. Does it also need to be displayed on a map?

Currently, nested views creation is not supported at the moment inside the block editor. Check this screenshot hidden link

So I created a view with the legacy editor and configured it to display the Rallies of the current Park in the loop, check this screenshot hidden link

But, this has, actually, some limitations. Especially if you want to have the results on a grid. The parent view is created with blocks and is configured to display a grid of Parks. Then the nested view will display its results(Rallies related to the park) inside the park's grid cell, especially if a park has more than one rally. You may end up having grids inside grids. It may also have issues for pagination. Does it make sense?
Check my simple example result's in this screenshot hidden link

If you want to display each rally on a grid cell, and you have some parks with more than one rally, I'll suggest you build the parent view with the legacy editor. The loop code can then use Bootstrap classes to have the proper results. This solution may also present some pagination inconsistencies because the parent view is the one who controls the output.

There maybe another solution involving custom code, where we can use one view to query Rallies, and hook into the its query to make it search only within the parks that satisfies the search criteria. The solution will use the wpv_filter_query hook, the post__in WP_Query argument, and the toolset_get_related_posts relationship function:
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
- https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

I'll let you check the view that I have created. Let me know if you have any questions, and if the results should go into a map.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.