Skip Navigation

[Resolved] Best Practice on setting up many-to-many relationship Teams/Players

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 4 voices.

Last updated by Christian Cox 7 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#538888

Hello,

I am setting up website for a university sports team club. We archive information on teams, players, along with roster for the various teams.

I want to capture the following information about the teams

Year
Sport
Players

For example

1995
Baseball
Player 1, Player 2, Player 3, Player 4, etc.

For each sport there would be years from 1910 - Current
There may also be players that play multiple years of a sport and/or different sports.

Can you give me some ideas on how to best set this up to optimize this data?

#538902

have you tried this ?
hidden link

#539101

Noman
Supporter

Languages: English (English )

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

Hi Tims,

Thank you for contacting Toolset support. To achieve this you need to use parent child relationship.

Create:
1. Team - Parent CPT
2. Year - Multiselect field
3. Sport - Category/Taxonomy
4. Players - Child CPT

Create a View for Team CPT and add Years, Sport and Players in this View.

Here is related doc:
https://toolset.com/documentation/toolset-training-course/part-8-one-to-many-relationships-in-toolset/

Thank you

#540973
clip3.PNG
clip2.PNG
clip1.PNG

Hello,

Thank you very much for your response. I am getting the hang of this but have a few quick questions.

For my teams should I name them like Football 2000, Football 2001, and then just type in the year into my custom year field i've created and select the sport? That way when you view the sports team names they don't just all say Football for example?

How can I allow players to be part of multiple teams? For example, they may play in the 2000, 2001 and 2002 Football team. or they may play 2001 Football, 2001 Baseketball, for example.

How can I add the team members position in with their team. For example "Defensive Tackle"? Would this be a taxonomy?

#541670

Hi, Noman is unavailable today so I will be taking over this ticket. I hope that's okay with you.

For my teams should I name them like Football 2000, Football 2001, and then just type in the year into my custom year field i've created and select the sport?
This sounds fine to me. Keep in mind that the post title may be shown on a single post page, as well as any WordPress Archives, for Teams. So a descriptive Team name is a good idea.

How can I allow players to be part of multiple teams?
So in other words Players can be on multiple teams, and teams can include multiple players, right? This requires something we refer to as a many-to-many relationship. In order to accomplish this, you must create a 3rd custom post type to use as an intermediary between players and teams (and positions, as described below).
More information about many-to-many relationships here:
https://toolset.com/documentation/toolset-training-course/part-9-many-to-many-relationships-in-toolset/

How can I add the team members position in with their team. For example "Defensive Tackle"?
This can be handled several different ways, and depends on several factors.
Option 1 - use a custom field. All the options must be predefined in wp-admin. If you go this route, you must determine where the custom field should be set. If a player can be on many teams, then can they also play multiple positions? Can they hold multiple positions on the same team? If yes to either of these, then it's probably not best to put this custom field in the Player post type. It's probably better to include it on the intermediary post type, which is unique to each Player / Team / Position combination.

Option 2 - Create a custom post type for positions, and use a many-to-many relationship to associate Players, Teams, and Positions. This is probably the most flexible approach, but is also the most complex and can be a challenge to search and filter effectively. With custom post types, you get the benefit of WordPress Archives and single post pages already baked in for each position, each team, each player, etc. Positions will have their own editing screen like the Post editor in wp-admin. I recommend trying this approach on a very small scale to see how it all fits together.

Option 3 - Taxonomy. This is a good general option if you don't need the full features of a custom post type for each position. Again, try this approach on a very small scale to see how it works and how you can structure custom searches using this taxonomy.

The forum ‘Types Community Support’ is closed to new topics and replies.