• Resolved Jhonc66

    (@jhonc66)


    Hi,
    I am not a programmer to start with, so I may be looking for something very obvious for some people.

    I have created 2 Custom Field Types that have bi-directional relationships
    1.Events
    2.Trainer

    the Idea is to display the events a trainer has won. i.e
    John Doe – EventA
    John Doe – EventB

    My goal However is to display the amount of times the Trainer has won an Event so that each trainer page has a Bio with the amount of times he has won x Event i.e

    =======// John Doe Page //========
    John doe – 10 x EventA
    John doe – 5 x EventB

    =======// Anne Doe Page //========
    Anne doe – 5 x EventA
    Anne doe – 7 x EventB

    How would I do this in Pods.

    Thanks in Advance

Viewing 1 replies (of 1 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    Unfortunately to get a count of something that is specifically a count of a handful of items within a group, yes, you’ll have to use PHP. It’s fairly easy without code to output the list of events (you can see examples of this in our Video on Grow Beyond Posts & Pages, specifically around the 21 minute mark https://youtu.be/fxpH68u3sgw).

    Since you’re uncomfortable with code, the above method might work the best for you.

    But, if you’re trying to do things like output the list and only show summaries, you’ll need to loop through the related content and create a couple of variables to count based on the ‘event’. We have an example of outputting content from a relationship field, you could modify the section around foreach $related as $rel to actually build your own ‘award count structure’ in a variable, basically as you looped through the related records, you would increment a count for each ‘event’ and then just output that list at the end.

    I’m curious in your structure: Are all the related events, events that these folks have won? It might make more sense to add an additional custom post type called ‘awards’ and that would include a relationship to ‘people’ and ‘events’ and only the people that won awards would be listed in this post type. Easier to output for each person that way how many events they had won for that particular award. Just a thought.

    If you’ve got any more specific questions, please feel free to join our Slack Chat at https://pods.io/chat/ and we’ll try to help you out ??

Viewing 1 replies (of 1 total)
  • The topic ‘Amount of Events in Relationships’ is closed to new replies.