Home › Toolset Professional Support › [Resolved] Setting up a view with mixed data between two relationships.
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10: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/Kolkata (GMT+05:30)
This topic contains 10 replies, has 2 voices.
Last updated by brettB-4 1 year, 7 months ago.
Assisted by: Minesh.
We have our custom content types of Team and Match. I successfully set up a view showing match results here:
hidden link
We are also working on a Standings page as the next step. Luo Yang has provided help to get us most of the way there on this page:
hidden link
Now for the final step for the Views we want to create to show Results and Standings, I am now trying to set up a new page with a view to show Standings, but with round by round results also present. If you look at our spreadsheet file here:
hidden link
What we are trying to do now is all the standings tables that are on the left side of this spreadsheet. This entails showing elements of both the Standings and the Results page. So I saved this one for last figuring it might be the most complicated. I have started setting up the view for this and have it displaying on this page:
hidden link
The problem I'm having is I can't seem to get any data to display. The table is structured how we want it to start, but the data doesn't show up. The View I've set up is here:
hidden link
My loop item in this view has the following:
<td>[types field='team-name' item='@team-1-match.parent'][/types]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td>
<td>[types field='team-name' item='@team-2-match.parent'][/types]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td>
<td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td>
But that is displaying empty table cell results across the board.
I can't figure out how to choose Teams as the content to display and to pull the scores from the games through the two relationships between Team 1 and Matches and Team 2 and Matches. It looks to me like the table created by my view does have the correct amount of rows showing, but the field data does not display. When I change the view to show Matches, it shows data, but it's not what we're wanting.
Note also that this view is currently set up to only display results from Men's Doubles. We have Men's Doubles, Women's Doubles, Mixed Doubles A and Mixed Doubles B matches. I'm trying to get Men's Doubles to work first. If I can get this to work, then I'll just duplicate this and change the fields for each group. So having different tables for each group is one part of this. But then the other part is I conditionally display the scores from each Round in the R1, R2 and R3 columns. The Round number is defined within Matches. Once I have this working, then I will also have to conditionally add columns for R4 and R5 for one of the sessions. One of our sessions has 5 rounds instead of 3. I just want to get it working with 3 rounds first.
Is there any way you could look at how I've set up my view and determine why I'm not getting any field data in the table? I can't figure it out.
Once I can see the data, then there is going to be another difficult step to this. See how I have it set to display Team 1 scores and then Team 2 scores? The reason for that is because a Team can be Team 1 in one Match, but then Team 2 in another Match. I just planned to get all data showing in this view first. Then I was going to ask if there is any way to combine the results under one of these showing just Team Name, R1, R2, R3 and total, not broken up by Team 1 and Team 2. If I set the relationship to be on Team 1 to Match, then I won't get any data for that team on matches where they are Team 2. This table uses both relationships, Team 1 to Match and Team 2 to Match. I'm thinking I might need to restructure everything here to do this a different way. It's possible that should have set up a many-to-many relationship to allow 2 teams per match and multiple matches per team. Initially I was thinking there would be advantages to specifically define Team 1 and Team 2 separately, but now I'm seeing that there may be more disadvantages to doing that. I hope I don't have to redo everything with this, but I will if I have to.
For the purpose of this ticket, I'm just asking for assistance in determining why the field data isn't displaying on this view. I just wanted to give all this background in case the way I've set things up is the reason this view isn't working, so you could then tell me what I need to do instead.
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details and let me check whats going wrong with your setup.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Could you please check now: hidden link
Actually you set your view to display/query the "Team" post type and you added the following code in the view output:
<td>[types field='team-name' item='@team-1-match.parent'][/types]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' item='@team-1-match.parent'][/types][/wpv-conditional]</td> <td>[types field='team-name' item='@team-2-match.parent'][/types]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' item='@team-2-match.parent'][/types][/wpv-conditional]</td>
So you are trying to display the parent value but actually "Team" post type is parent and the field which you are trying to display (team-1-score-mens-doubles and team-2-score-mens-doubles) is belongs to child post type "Matches" which is child post type.
So, I've set your view to display/query the post type "Matches" and changed the view output as given under:
<td>[types field='team-name' item='@team-1-match.parent'][/types]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-1-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td> <td>[types field='team-name' item='@team-2-match.parent'][/types]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 1' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 2' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td> <td>[wpv-conditional if="( $(wpcf-round) eq 'Round 3' )"][types field='team-2-score-mens-doubles' format='FIELD_VALUE' ][/types][/wpv-conditional]</td>
I can see it does display the correct value on the page: hidden link
Yeah, I tried displaying Matches and I did get some results, but it wasn't right. What you have done here is also giving results, and these results are very different from what I saw on my effort with it as matches, but this still isn't right.
Each team should only display on one line with the scores for each match showing on that same line. Because I only wanted one team per line, I determined that I was wanting to display Teams and I was hoping to get the Match results for each team in through the relationships with Matches.
So instead of showing each Match on a separate line, it should show as follows (I'm just using the first two Teams for this example)
Team Name R1 R2 R3
Canton Pickle Smack 21 15 18
Augusta Dinking Buddies 14 13 19
and so on for every Team in the system which we'd then try to separate by Session as it is done on the left side of the spreadsheet file I'm trying to emulate:
hidden link
Once that's done, if it is doable, I'd then try to add a field to the end that would calculate the sum of the three rounds to provide a total. Once that's done, if it is doable, I'd then emulate this view for Men's Doubles to provide the same output structure for Women's Doubles, Mixed Doubles A and Mixed Doubles B.
I told Luo Yang in our other currently open support ticket that we fully understand if this is something where we'd have to hire a contractor to get this higher level functionality done. But we'd much prefer to pay you guys to handle it over your listed contractors due to a VERY negative experience I had with one of my other clients when we hired one of your contractors.
I see you are displaying Team 1 name and Team 2 name in the able currently:
- hidden link
Do you mean that you want to display team name and R1 R2 and R3 values now so just 4 columns?
It needs to be less rows. See how the first row displayed has Canton Pickle Smack, but it is only displaying the result from the Round 3 match there? It should have all three Canton Pickle Smack match results on that single line. Then the same for all other teams showing all of their results on the one line for that team. The way it is working now is displaying all matches one at a time. We need it to display all teams one at a time. But when I set the output to display Teams to accomplish that, all records are empty. The team names don't even display.
The reason I have Team 1 name and Team 2 name on the table is simply because I don't know how to combine them to show on the one line. A team can be Team 1 in one match and then Team 2 in another match. We need just the team name and then the three results from their matches, whether they are Team 1 or Team 2 in that match. My first step was to get all teams displaying with the match results and then see if there is a way to combine results from when a team is Team 1 in a match with results from when the same team is Team 2 in another match. I'm trying for functionality that is well beyond my skill level here, so I have to take it one baby step at a time in trying to get it. Then when I hit dead ends with what my knowledge level with Toolset allows me to do, I file tickets to see if you guys have solutions that I don't know about.
It is possible that my whole approach of having a Team 1 and a Team 2 defined for each match and using two different relationships is the start of a major logic flaw. I thought that would be the way to accomplish what we're trying to do. It has worked to get us most of the way there with Teams, Matches, and Results showing all matches with scores. But it is proving to cause major difficulty with creating Standings. If I have to restructure everything, I'll do so. I knew all of this would be very difficult to achieve. When I started on everything for this site, I did so just intending to see how far I could get with it, but unsure if it would be successful. I'm still hoping we can get it because, if successful, we plan to start marketing this as a website development package we can sell to leagues in this sport and perhaps other sports anywhere.
I think the flaw in my approach is that there doesn't seem to be a way to get match results to attach to the team they go with. I thought the relationship between Teams and Matches would accomplish that. But it seems like I have to display Matches for that to work and I can't display Teams. For instance, if I display just a team name and then the scores, there isn't anything attaching the scores to the team. So if I display just team names, there is no way to know if their scores in each match should be pulled from team 1 or team 2. In order to achieve what I'm trying to do, it seems like all match scores somehow must become fields within Teams. All the Match scores need to somehow get fed to the appropriate Teams. Maybe I just have to create the same score fields within the Teams field group in order to achieve this. I was hoping for a way this could be automated to where admins only have to enter match results as they happen, but it's looking like scores have to be entered in two locations to get everything.
The site structure is on you we do not suggest strongly that you have to follow site structure, relationships that we suggest as we do not know your whole project scope. Support role is to offer you assistance where you stuck and offer you support for Toolset.
In such a care I strongly suggest that you should create a test site on our free test platform http://www.discover-wp.com or even you can install our reference site using our framework installer plugin on your local server.
On downloads page you should click on the tab "Reference Sites": https://toolset.com/account/downloads/
- At bottom of the page you can find the framework installer plugin.
By installing test site you can first run a test and build relationships, post types, custom fields and whatever you want and check first whats possible with Toolset and what workaround you can use if there is no function available with Toolset.
So at this moment as well I strongly suggest first you create a test site and check by created many-to-many post relationship between Team 1 and Team 2 and then as intermediary post type will be the matches fields.
Does that sounds good?
Yeah, I can give that a try. Is there any way to easily export Match and Team content from our site to this site? It would be best if I could test using our real data here, but it would take me several hours to rebuild all of that content. If not, then I'd just test using 4 teams and 3 matches for each.
But first, here's another question for you though as I was thinking of another approach to this. Feel free to split this into another ticket if need be. I'm seeing that the limitation here and in the other ticket Luo Yang is working on for us is that there is no way to get the Match scores to associate directly into the correct Team post and the relationship doesn't allow for those scores to be tallied within a Team view display. So now I'm thinking that our score field data has to be saved twice for me to be able to get Standings functionality to work. The scores and Win Loss results must be present as fields in both the Matches content type AND the Teams content type. If I can get that, I think all these dead ends being hit can be worked through.
So my question here now becomes the following: Is there any way for a field in a Post Form for one content type, also save to a corresponding field in another content type? Can it be pushed to save to two locations? Or is there another way to link two fields within two different content types to make them stay the same when one is updated? If it can, then I think that would solve things in an automated way that would be perfect. If it can't, then I think the solution to all of this is that the Team score fields must be manually entered in the same way Match scores have to be added as an additional manual step an admin must take. So on the view I have already set up showing all Teams, I'd need to add an edit link that would lead to an Edit Teams post form, and the admin would have to add match scores there as well after also adding them through the Match post form. That would double the work that the admin has to do manually, but if that's the only way to accomplish the goal, then that's what must be done. Let me get your answer to this question before I try the test platform approach.
New threads created by Minesh and linked to this one are listed below:
Yes it would be nice to create another ticket from your last post and you are welcome to close this ticket.
I'll make another ticket if I end up setting up a test site to try to do this with many-to-many relationships instead of how I currently have it structured.
Note that I said this was very hard to solve the problem above because of the difficulty of the problem itself. That shouldn't reflect poorly on your assistance here, so make sure anyone that judges your work on that rating sees this comment from me. Minesh's help was FINE! The problem is what's very difficult here.