You are saying it's possible to make the CRED form for "create team" and "join team" conditional based on how many entries the tournament author decides?
I'm saying it's possible to display the form using conditional logic, based on the value of a custom field in the current tournament. The form itself does not include conditional logic. If you are displaying a tournament post, you can access information from a custom field in that tournament post using the [wpv-post-field] shortcode. You can also count the number of child posts in a specific post type. If the number of child posts is less than the custom field number, you will show the CRED form or a link to the cred form. More info below.
How would I create a conditional output depending on the custom field input?
In this example, TournamentTeams is a custom post type used as an intermediary to define a many-to-many relationship between Tournaments and Teams. Therefore TournamentTeams are children of a Tournament in a one-to-many relationship. The general idea is to create a View of TournamentTeams, filtered by post relationship. The parent Tournament should be the current page or post. Inside this View, you can apply a conditional like this:
[wpv-conditional if="( [wpv-found-count] lt [wpv-post-field name='wpcf-num-teams' id='$tournament''])"]
... your cred form goes here...
[/wpv-conditional]
<wpv-loop>
... you can leave this empty, or add information about each team here.
</wpv-loop>
Then place this View on the Tournament posts inside a Content Template or Layout for Tournaments. This counts the number of child TournamentTeams and only shows the form if the number is less than the "num-teams" field on the current Tournament.
Is there any further documentation about conditional outputs?
All the documentation I'm aware of is accessible through links on this page:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
If you have specific questions, feel free to open tickets so we can address those for you individually.
do you have an idea for how to solve the fixture generation?
This sounds fairly complex, if I understand you correctly. You would like the system to generate Fixtures, or "matches", automatically, at random, for all TournamentTeams in a Tournament, right? You've got a lot of functionality to figure out here, like what happens for an odd number of Teams, when do the Fixtures get set in relation to the Tournament and Team posts, what happens when a Team drops out before or after the tournament, what happens if no Teams sign up, etc. This is all logic that you would need to figure out and code on your own using PHP.
At the most basic level, you need to be able to create a Fixture post that includes custom fields that define TournamentTeam1 and TournamentTeam2 for this Fixture. You need to be able to determine which TournamentTeams have not been assigned to any Fixtures yet, so you would use wp_query to find that out. Then you can use wp_insert_post to create a Fixture post with the correct meta information.
https://developer.wordpress.org/reference/functions/wp_insert_post/
You need to be able to trigger this Fixture post creation process using certain criteria:
- Trigger it first when the number of TournamentTeams meets the maximum number of Teams allowed by the Tournament, or some other custom criteria you define elsewhere. You can use the save_post hook to check the number of TournamentTeam posts each time a Tournament or TournamentTeam is saved.
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
- Trigger it again repeatedly until all TournamentTeams are included as team1 or team2 custom fields in at least 1 Fixture in this Tournament. What happens with an odd number of Teams, I'm not sure and you would need to work out.
- Possibly trigger it again if Teams drop out or are added later? Up to you.
This is just off the top of my head, but you can see how there is a complex set of functionality to build out, and it's far too much to try to accomplish in one ticket. When the code is directly related to Toolset I can help, but much of this is unrelated to Toolset so you would be on your own. If you have individual questions about specific parts of this process that are related to Toolset, feel free to open tickets and we can try to help.