Skip Navigation

[Resolved] Displaying a categorized many-many relationship

This thread is resolved. Here is a description of the problem and solution.

This support ticket is created 4 years, 1 month 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 2 voices.

Last updated by brianW-8 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1814979

So I've been through the documentation and either I'm dumb (possible) or you don't directly address this issue.

I have a site that has a many to many relationship between college campuses and resources. Basically, each campus can have many resources, and each resource can apply to multiple campuses. So far so good.

The resources have categories, created with a custom taxonomy. For this discussion, let's say Category 1, Category 2, etc. Each category actually has sub cats as well: 1-1, 1-2, 2-1, 2-2, 2-3, etc. Complicating this is that a Resource has a yes/no field (a checkbox) that defines it as a NATIONAL resource, which means it should show on ALL campuses, whether or not it is specifically attached to that campus.

I need to craft the Campus template in such a way that it pulls the list of all associates resources, AND national resources, sorted by category and sub category. If possible, I also need to inject anchors into the resource list at each category and subcat heading for navigation (we're going to use on-page anchors and a sticky navigation to navigate what will be a VERY long list of resources for each campus.)

So, what I need on the Campus template should be something like this:
CAMPUS NAME (Campus field)
CAMPUS INFO (Campus field)
Resources (Static Heading)
Category 1 (Dynamic based on the Taxonomy, with anchor)
Category 1-1 (Dynamic based on the Taxonomy, with anchor)
RESOURCE NAME (Resource field)
RESOURCE INFO (Resource field)
<hr/>
RESOURCE NAME (Resource field)
RESOURCE INFO (Resource field)
Category 1-2 (Dynamic based on the Taxonomy, with anchor)
RESOURCE NAME (Resource field)
RESOURCE INFO (Resource field)
<hr/>
RESOURCE NAME (Resource field)
RESOURCE INFO (Resource field)
Category 2 (Dynamic based on the Taxonomy, with anchor)
Category 2-1 (Dynamic based on the Taxonomy, with anchor)
RESOURCE NAME (Resource field)
RESOURCE INFO (Resource field)
etc. etc.

I hope this makes sense. It seems like it shouldn't be too tough, I've just been banging my head against it for a few hours and can't figure it out. Thanks for the help.

(PS, the actual staging site isn't swy.lpcstaging.com, it's swy2.lpcstaging.com. I this is the second staging, I haven't gotten around to moving the license over yet.)

#1815985

Hello,

It is possible with a nested view, for example, you can try these:
1) Create a taxonomy view "Parent taxonomy view":
- Query terms of "Category"
- In view's loop, display below child post view

2) Child post view:
- Query "Resource" posts
- Filter by:
a) post type relationship between "Resource" and "campus"
b) Select posts with taxonomy:
Categories set by the parent Taxonomy View
- In view's loop, display the "Resource" post information.

More help:
https://toolset.com/documentation/user-guides/views/using-a-child-view-in-a-taxonomy-view-layout/
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

#1816359

Maybe I'm being dense, sorry. I can create content templates, but I'm using Toolset Blocks, are templates the same as views for this purpose? Or do I need to uninstall blocks and use Toolset Views?

#1816959

Q1) are templates the same as views for this purpose?
I assume we are talking about Toolset Content Template.
If it is, the content template is for rendering single post, but Views is for rendering multiple posts, they are different.

Q2) Or do I need to uninstall blocks and use Toolset Views?

You don't need, the Toolset Blocks plugin is advanced version of Toolset Views plugin, we recommend you to use Toolset Blocks plugin in your new projects.

With Toolset Blocks plugin, you can enable the classic editor GUI by these:
Dashboard-> Toolset-> Settings-> General:
in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build".

Refresh the page.

Dashboard-> Toolset-> Views, here you can setup post/taxonomy views with classic editor.

#1817895

Thanks for that. I think I'm getting there.

So is there an example somewhere that's close to what I'm trying to do? or can you give me a little more info? Like which views do I need to create and nest to pull off the recursive list I'm trying to get? (See first message for the example.)

#1818557

Please have a look at my first answer:
https://toolset.com/forums/topic/displaying-a-categorized-many-many-relationship/#post-1815985

In the documents I mentioned above, there are examples and detail steps.

If you need more assistance for it, please provide a test site with the same problem, also point out the problem page URL and view URL, I can setup a demo for you. Private message box enabled.

#1819173
2020-10-21_11-14-40.png

We might get to that point, but one issue I'm having following your documentation is the links to the reference sites are broken. I tired to click on the link to the "WordPress Magazine Site" (https://toolset.com/reference-site/toolset-magazine-site/) and get a 404 error.

Has that been taken down or moved? Can I get a link to that? I think that if I can see that I can figure out .

Specifically, I can't find the attached filter when creating a taxonomy view. I see this in the documentation but not in my install.

As I understand it, I need to create three nested views:
A master taxonomy view that pulls parent categories; a nested taxonomy view that pulls the sub-categories for each parent; and finally a post view nested that pulls the resources from that category. Do I have that right?

One question I might need to ask eventually is this: Since this is all on a content page for the campus, that third "post" view will need to only pull resources associated with that campus, I'm not looking to pull ALL resources from the sub category.

#1819679
child.JPG
sub.JPG
top.JPG

Unfortunately, the document you mentioned above was removed, but I can provide those screenshots.
1) You need to enable classic editor, by these:
Dashboard-> Toolset-> Settings-> General, in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build", so you will be able create those views with classic editor.

2) Top level taxonomy view: top.JPG

3) Sub level taxonomy view: sub.JPG

4) Child post view: child.JPG

For your reference.

#1825015

Sorry it's taken so long to respond. Ok, I think I've got it all almost working! I've got the recursion and got it pulling things up properly. Two more questions:

1) I need to customize the full page display of the custom post type. Specifically, I need to remove the sidebar and make the content full width. Does Toolset have a way to do this or will it always display inside whatever the theme has set as the default single.php content area?

2) After I've created a relationship, I know I can attach related resources on the campus page with the "Add new Resource" but only custom fields are shown when creating. Is there a way to enable the "normal" fields, specifically, I need the user to be able to enter the main body of the post, which I'm using as the long description of the resource.

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/two-more-questions/

#1825545

I assume the original question is resolved, according to our support policy, we prefer one ticket one question, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/two-more-questions/

#1827519

My issue is resolved now. Thank you!