Home › Toolset Professional Support › [Resolved] Can fields within a custom field group get associated with each other ?
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 27 replies, has 3 voices.
Last updated by brettB-4 1 year, 7 months ago.
Assisted by: Luo Yang.
We're trying to create a Standings page on the site next. I'm sure this will be the toughest test of Toolset functionality that we'll have here. We have Teams functionality already done and we have Matches functionality with scoring and Results mostly done, save for the other pending ticket being worked on for getting grouping/sorting on the Results page.
Within the Teams custom field group, I've added number fields for Wins, Losses and Total Points.
Within the Matches custom field group, I've added number fields for the following:
Team 1 Score - Men's Doubles
Team 2 Score - Men's Doubles
Team 1 Score - Women's Doubles
Team 2 Score - Women's Doubles
Team 1 Score - Mixed Doubles A
Team 2 Score - Mixed Doubles A
Team 1 Score - Mixed Doubles B
Team 2 Score - Mixed Doubles B
Each match consists of these four games between two teams and these fields give the scores for each team.
Then I also have the following two additional radio button fields:
Team 1 Result
Team 2 Result
The radio button options on these fields are Win and Loss.
All those fields are serving their purposes well for us on the Results page already.
What I need to ask here is to see if there is any way to associate each of these fields with the correct team in each Match for the purpose of trying to build a Standings page.
Team 1 and Team 2 names are defined on the Post Form that creates Matches through the Relationship with the Teams content type. All Teams in the system are available in the dropdown and the two Teams are chosen for each Match there. So what's needed is a way to associate the four Team Score fields and the Team Result field with the team that was chosen in each Match. Is there any way to accomplish this?
Note that a complication to this is that any Team can be Team 1 in one match, but then be Team 2 in a subsequent match. So the fields within the field group need a way for the data to be fed to the appropriate Team within each Match.
If there is a way to do this, then I will later need to learn how to do calculation functions within Toolset to add the Team Scores numbers to the Total Points field within the Team content type and to add the Team Result conditionally to the Wins or Losses field within the Team content type. I've already read some support tickets that cover math/calculations, so I'll get as far as I can with that on my own first. But I'll stick to the first question here to see if you know of a way these scores and results can be associated with the correct team. I realize your answer here MAY force to me restructure EVERYTHING I've already done another way to reach the goal. If this can't be done, then I'll have to drop the idea of setting up a Standings page.
But if we can get this functionality in place, the plan is to package this as something we can provide to other leagues anywhere. So if we can succeed with this, that plan will involve landing many new clients that will all purchase Toolset. Any help you can provide to get us to this goal will be greatly appreciated and will allow us to try to get many more Toolset customers for you. I realize we're seriously pushing the functionality of your plugin here.
Hello,
How do you setup those custom fields?
Here is a sandbox website:
Login URL: hidden link
You can reproduce the same problem in above sandbox website, I need a live website to test and debug, thanks
Is there any way to import all the Toolset custom field settings and custom post type settings and then also all the Teams and Matches already set up into this sandbox site? We have all the content types, fields, and Teams and Match results set up on the real site, but that will take MANY hours to redo all of that. I can redo it all if need be, but I first wanted to run it by you that it's totally OK for our request here to be done on the live site. We no longer have an active tournament where there is a lot of site traffic happening.
We can put this site into maintenance mode if you need to disable anything for testing. But we don't have anything that isn't working or broken that needs debugging and what you do won't impact anything being looked at by end users now anyway. We do not have the Results page or Schedule page set up for public display yet by being in the top menu, and we won't have this new Standings page visible either. The only Toolset generated View content we have on a page is the individual Team pages running through a Toolset template and the Teams list page through a Toolset View. But it doesn't matter if any of that gets messed up at this point. We can just take down the Teams page from the menu if need be so people won't see it.
This is just a request for assistance with whatever needs to be done structurally to somehow get the score and win/loss result fields passed from the Match posts to the correct Team posts. I can backup the actual site so we can restore to that any time if necessary. If we get all of this working, then we'll add these pages to the top menu for public viewing before the NEXT tournament, not for the one just completed that gave us all these matches and results I've already set up. We're just using this tournament data from last weekend's real tournament so we have real life examples to test with and compare to a spreadsheet file the client has that has all the desired information in it. He provided me this spreadsheet file and said "This is what I want" and I'm trying to emulate everything in that.
But if there is another reason for using the sandbox site to make everything easier for you, let me know and I'll go ahead and redo the work here.
The part where I'll need to learn math/calculations is as follows:
The addition of a Team Result field option of Win in a match should add one to the Number field for Wins on the Team field.
The addition of a Team Result field option of Loss in a match should add one to the Number field for Loss on the Team field. The better approach would be to pull all Match data into a view and have the Wins and Losses fields be a count of each corresponding one in the Matches. That way if a Win/Loss result is entered in error and has to be changed, that possibility won't have to force a change to the number present reducing the errant entry by one and then adding it to the correct field. The View will just pull all Match results as they appear at that time.
The addition of all the game score fields should add all four game results within each Match to the Total Points field on the Team field. That should be pulled by a View in some way as well. So the Total Points field should simply be a calculation adding every point scored in every game of every Match for each team.
I'm just letting you know this in advance just in case this knowledge will be helpful to you in knowing the structure that will be best for the initial request. Don't worry about doing anything with that yet as I understand you only want one item per ticket. I'll get as far as I can with that effort before submitting another ticket for anything with that. I'm hoping that I'll be able to do everything with that if you can get it to where this field data associates with the correct teams in each Match in a way where this can be easily pulled into a View.
Once we have this done as a proof-of-concept for this league, then we plan to put together a sales package for this website functionality to approach other leagues for this sport worldwide. This client also has a serious physical product that can provide a tremendous service to any of these leagues that they plan to market/sell to them too, so they will already be approaching many leagues with that effort. This will be something else that can be pitched simultaneously.
OK, please:
- Backup your website first,
- Provide your website credentials in below private message box, thanks
Thanks for the details, I am checking it in your website, will update here if find anything
You can not associate post fields of "Match" post with other "Team" post directly, there isn't such kind of built-in feature within Toolset plugins.
But since there are two one-to-many relationships between "Team" and "Match", so there are indirect relationship between them.
Can you share a demo of your client desired information spreadsheet file? I need to check if it is possible within custom codes or other kinds of post type relationships
The URL to the spreadsheet is here:
hidden link
I'm not sure what's needed for you to have permission to view it though. Let me know if you can't access it and I'll find out what we need to do to get you access.
Note that I have set up the start of a Standings page here:
hidden link
Note that we'll want each session separated. The primary sort will be by session and the secondary sort within each session will be by Total Points. But don't worry about this grouping here. That will be another support ticket. Minesh already helped us set up similar sorting/grouping on the Results page. I've tried to emulate his approach, but my effort resulted in an error. I just wanted you to see this to get more of an idea of what we're going for.
The spreadsheet has more than what I've set up here. I'm trying to do this one step at a time.
The first step was getting single Match totals. I have that done here:
hidden link
I didn't need to have the score fields get attached to the Team for that step because all those fields were within the Match post type and could be calculated in the View displaying Matches.
The second step is getting the overall Tournament totals for each session, which is what I'm trying to do on this Standings page. That is where it becomes necessary for all these score fields within each Match to get assigned to each Team appropriately.
Then there will be a third step to get the Round-by-Round totals within each Session, but don't worry about that now.
The client said just the URL to the spreadsheet should work for you. Note that the part we're working on here with Total Points is just the small green box saying Total above where it says Play-off Round on each of the tabs.
We're also adding the Wins and Losses functionality here because we want to make sure we can do it that way for future tournaments or for other sports leagues that base their standings on Wins and Losses instead of Total Points.
I've just created another view that gets the fields down to the barest basics of what's needed and may make it easier to add custom code to accomplish the mission here. This view shows all matches and just has Team 1 Name, Total Points, and Result and then Team 2 Name, Total Points and Result.
That view is displaying on the page here:
hidden link
You can see the View here:
hidden link
So what's needed is a way to add numerical data for each loop item here as follows:
The field "Team Name" has to be what determines which team post gets edited. This is what I understand is the hard part here and may be beyond the capabilities of Toolset. I'm guessing something will be needed here to get the post ID that corresponds with each Team Name. Note also that the Team Name field here will always coincide with an existing Team post title. The Team Name field in both cases of Team 1 and Team 2 are selected in dropdowns containing Team post titles. So that should make it easier to determine the post ID for them.
The field "Total" should add itself to the Total Points custom field in the Teams field group within the Team post corresponding to the Team Name. This addition should be a mathematical calculation to add itself to what was in the field previously. So when all loop items complete, the final result will be a tally of all points scored by that team.
The field "Result" should conditionally add the number 1 to either Wins or Losses custom fields in the Teams field group within the Team post corresponding to the Team Name. This too should be a mathematical calculation to add that 1 to what was in the field previously. So when all loop items complete, the final result will be counts of how many times each team won and how many times they lost.
For the question: something will be needed here to get the post ID that corresponds with each Team Name
Yes, you can display the team's post ID with shortcode, for example:
Team 1 post ID: [wpv-post-id item='@team-1-match.parent']
Team 2 post ID: [wpv-post-id item='@team-2-match.parent']
And if you don't need to store the total values, it is possible to use custom JS codes to sum total score, count total win and total loss for each team, please let me know if you need assistance for it.
I have setup a demo in your website:
hidden link
Please check section "Team posts"
Is it what you want or not?
WOW!!! This is looking seriously good! I'm going to try to do a few minor modifications to what you have here first, and then I'm going to try to break up the results by Session. If I can get these grouped by Session that will be it for this step. I'm trying to set up a session filter now and was able to get that mostly working. That's probably even better than sorting and grouping by session. But I'll probably play around with how this displays some more. Excellent!
I also have to double-check all the point totals to make sure those are right, both from the results of what you've set up here and from what I've entered for individual Match results. If all is right here, then this is completely awesome! I was thinking we wouldn't be able to get this.
I'm looking at the javascript code you added and I have no idea how it is bringing in the score and result data to tally. Obviously it's working, but you're so far over my head with this, it's ridiculous. I was hoping to at least be able to see how this was accomplished and understand it, even if I'm not good enough to code it myself. The shortness of the code has my head exploding as well. I thought it would be much more complicated than this.
Now i went into one of the team edit pages and I'm seeing that the Total Points field and the Wins and Losses fields within the Team posts are not being populated with these results. You're just obtaining what's needed to produce those results for display with the View outside of that. Is there any way to push your results to those fields in each Team post and have them save? I suppose it may not be necessary for that to be done since you have it working without it, but it would be of help to me in setting up additional Views as they are needed. If it populates those fields appropriately within each team post, then there is a MUCH greater chance I could do additional things with that data at my level of Toolset knowledge without having to file another support ticket seeking assistance each time. But no worries if that can't be done or if I'm getting too greedy hoping for that.
THANKS IMMENSELY for getting it this far.
Let me keep this ticket open while I experiment with this and double-check the math on everything.
Is there any way to get the results to sort descending by the Total Points field?