Skip Navigation

[Closed] Having trouble creating a complex many to many sorted list

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

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 3 voices.

Last updated by Waqas 8 years, 5 months ago.

Assisted by: Waqas.

Author
Posts
#341171
what-i-have-now.jpg
desired-result.jpg

My question is related to the project you helped me with in this thread https://toolset.com/forums/topic/i-set-up-a-many-to-many-relationship-as-described-on-this-site-the-intermediary/

In my many to many relationship I am able to query the camps that belong to a particular venue. (what-i-have-now.jpg) I would like to add to that by sorting this list in a specific way.
1) Each camp as an assigned custom taxonomy (camp-type ie: technology, creative, educational, etc.)
2) I would like to group this list by camp type.
3) I would prefer not to have this query in a single view because the groups of camp-types have to be in specific static order and have different CSS classes applied to the elements.
4) So my query would be: Select camps that belong to current venue grouped by camp-type ordered by camp name (camp name is a link).

Let me know if I am being clear enough.

#341405

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

In the context of "Select camps that belong to current venue grouped by camp-type ordered by camp name", I suggest following work around:

- Create a child view to query the camps, there should be a Post Relationship filter applied and set to "Posts where the view is inserted" (see https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/)

- Insert the child view in the venue view's loop

This way when your venues view is rendered, it also renders the camps view within it's loop. So you will have camps related to a particular venue listed out on the page.

For more information, I recommend reading following guides also:

- https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
- https://toolset.com/documentation/user-guides/displaying-related-child-posts/
- https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
- https://toolset.com/documentation/user-guides/using-a-view-template-in-a-view-layout/

The second last guide is useful in an event, when you want to grab some information from a parent post, within the child post. While the last guide link is useful when you don't want to rewrite the same output for multiple views or want to use a common output code for multiple views.

#341872
camps-view.png
340783-list_venu_camps_view.jpg
list-camps-group-by-category.png

Hello, I am still having trouble writing the correct view.

With your help I was able to select all camps and group by camp-type taxonomy. (list-camps-group-by-category.png)
hidden link

With the many to may relationship I have set up, Camps, Sessions, Venues
I was able to create this view that lists camps that belong to a specific venue (list_venu_camps_view.jpg & camps_view.jpg)
hidden link
However, I can't figure out how to group this list by camp-type taxonomy as i did in the first link above.

#341982

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Unfortunately Waqas is off today. He will be back on Monday. This is Minesh here to help you further, hope this is OK.

I would like to have access of your install in order to have a better understanding of your post structure.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#342359

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for providing the details. Please allow me some time to work on this. I will update you as soon as I find a solution.

#342662

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Please see it working at hidden link

I created a demonstration for you and have added some visual stuff to make it self-explanatory. I have also used just titles of the posts to keep it simple.

Please see following 4 views created in Dashboard -> Views:

- Toolset: Camp Types
==> This is simple taxonomy view
==> showing all Camp Types
==> and is a parent view for "Toolset: Camps".

- Toolset: Camps
==> This loops through CPT "camps"
==> with a filter "Camp Types set by the parent View"
==> and is a parent view for "Toolset: Sessions".

- Toolset: Sessions
==> This loops through Intermediary CPT "sessions"
==> with a filter "Select posts that are a children of the Post set by parent View"
==> and is a parent view for "Toolset: Venues"
==> but with little extra record keeping. It passes the Camp ID to the "Toolset: Venues" as below:

[wpv-view name="Toolset: Venues" wpvprchildof="[wpv-post-id id='$camp']"]

- Toolset: Venues
==> This also loops through Intermediary CPT "sessions"
==> with a filter "Select posts that are children of the Post with ID set by the shortcode attribute wpvprchildof" (notice wpvprchildof attribute as mentioned in above code also). This attribute is received here and contains the Camp ID.
==> and displays the Venue Title as below:

[wpv-post-title id="$venue"]

The last 2 views are important to understand. Both loop through that Intermediary Object but behave differently. Since "sessions" is a child to both Camps and Venues, we can easily loop on the sessions, but can refer to their parents using that id="$venue" or id="$camp" attribute in the view short codes.

I hope, I have explained in detail and you can understand it easily.

The topic ‘[Closed] Having trouble creating a complex many to many sorted list’ is closed to new replies.