Skip Navigation

[Closed] Relationship between three Types

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Author
Posts
#1729311
Screenshot 2020-08-06 13.17.43.png

Tell us what you are trying to do?
I'm trying to show a table that gives an overview of a Company's Activities on a certain (educational) Level.

For an example see attached image.

How should I set this up in order to see this table in a View and be able to filter on it? I was hoping to be able to connect the intermediary type Activity-Level to a Company, but I don't see how.

Is there any documentation that you are following?
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-information-from-intermediary-post-types

#1729351

Maybe to elaborate: what I would like to have is a table that contains three (foreign key) id's:
1. Company id
2. Activity id
3. Level id

If you have another solution, I'm open to anything as long as it works: show as a table, be able to filter.

#1729743

Hello, in Toolset you have the ability to create many-to-many relationships between two Custom Post Types, not three. You have the ability to set custom field values for the relationship itself (i.e. on the intermediary post type), so I think you could accomplish most of this with a many-to-many relationship between Companies and Activities, and a custom field on the relationship that allows you to select a Level for each connection between Companies and Activities. So for example, you would create a relationship between Company A and Activity 1. In that relationship, you would select the custom field value of Level A. Would that work?

As far as displaying this information, are you hoping to generate something like what you've shown above, or is the spreadsheet pic just to help explain what you want to accomplish? If you want to show something like the spreadsheet pic, can you explain the filters you would like to include? By that I mean are you filtering by properties of the Company or Activity, or just filtering by Level, etc?

#1731745

Hi Christian, that is something I hadn't thought of before. Thanks for that and I'll try it immediately.

I want a table like in the picture to show these values on the site, yes. If that is not possible (or too difficult), I'm open to other ideas.

#1731747

Oh, and not to make it too complicated or anything. But is there a chance to import data into this new relationship? 🙃

#1732491

I want a table like in the picture to show these values on the site, yes. If that is not possible (or too difficult), I'm open to other ideas.
Well there isn't a GUI available to help generate this table stucture. For the full display, you would create a View of Companies and output the company name in the loop. Then you would separately create a View of the intermediate post type and nest it inside the View of Companies. In the View of the intermediate post type, you would output the title of the Activity parent post type as well as the value of the custom field. So that would produce a display something like this:
Company A
- Activity 1: Level A
- Activity 2: Level B
- Activity 3: Level B
- Activity 4: Level B
- Activity 5: Level C, Level D, Level E
Company B
- Activity 1: Level A
- Activity 2: Level B
- Activity 3: Level B
- Activity 4: Level B
- Activity 5: Level C, Level D, Level E
Company C
- Activity 1: Level A
- Activity 2: Level B
- Activity 3: Level B
- Activity 4: Level B
- Activity 5: Level C, Level D, Level E
If you wanted to produce a table of Activity and Level, you would need to create the markup for that table using custom HTML. To display a check or X for each cell in the table, you would need a conditional that tests whether the custom field for that intermediate post type contains the value for that column.

#1732987
image 1 - Screenshot 2020-08-10 at 13.26.46.png
image 2 - Screenshot 2020-08-10 at 13.28.30.png
image 3 - Screenshot 2020-08-10 at 13.25.11.png
image 4a - Screenshot 2020-08-10 at 13.29.57.png
image 4b - Screenshot 2020-08-10 at 13.29.35.png

Hi Christian,

Two problems currently:

1. After import of the activities and levels for each company, the levels don't show up in the Company admin view (see image 1). In the admin view of all intermediary post, I can see them and it looks fine (see image 2). How does that work? On a side note: the values of the custom field are stored in checkboxes with strings for both title and value to store (see image 3). When I export I get only 1's. E.g. 1 or 1,1 or 1,1,1. How do I know what values are checked?

2. I want to show the combination of activities and levels on a Company template. When I add a View to show the intermediary posts, the Current Post is Company and not Company-Activity (see image 4). How do I get the values of the intermediary post?

#1733033

I'm wondering now if I should add another relationship between Company-Activity and Level...

#1733615

I was thinking of using separate checkboxes for each level instead of one checkboxes group. Some import/export tools have problems with checkbox groups because the data is stored in a serialized format in the database, where single checkboxes are stored in single, separate postmeta values that don't have the same problems. Let me try to set up some similar test cases and see if I can recreate the problems you experienced to offer some guidance. I'll update you before the end of my day today.

#1741917
Screenshot 2020-08-17 at 13.27.57.png
Screenshot 2020-08-17 at 13.27.28.png

Hey Christian,

I got the problem solved where I can import and show Activities and Level per company.

The next thing that doesn't seem to work is the search box. I use the "Post relationship or repeatable field groups" field to show the Activities. I would need another field of the same type to show the Levels, I guess, but that's not possible. I can however add the Levels, but then nothing shows.

Thanks for helping me out.
Michiel

#1743169

If I understand correctly, you are trying to add a custom search filter to this View. Is that correct? Which post type is chosen in the Content Selection for this View? Normally a View will allow you to filter by the fields, terms, and relationships associated with the post chosen in Content Selection. So if this View is a View of the intermediary post type, then you should be able to add a Level filter here. Unfortunately you would not be able to filter by fields applied to the Activity or Company post type, but the fields applied to the Intermediary post type should be available for filtering. If this is not working as expected, I may need to take a closer look. Can you provide a login for me? Let me know where I can find this View on the front-end of the site so I can run some tests.

#1759447

Shane
Supporter

Languages: English (English )

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

Hi Michiel,

Sorry for the delay in response as the forum has been quite busy and Christian is currently on vacation and will return on Sunday.

It seems that you are try to achieve a fairly complex setup, would you be ok with waiting until Christian is back or do you want to continue here.

Please let me know.
Thanks,
Shane

The topic ‘[Closed] Relationship between three Types’ is closed to new replies.