Commons To Create A Sport/Player Management System

mcannon's picture

Hi,

I'm currently trying to build a small lacrosse community based on Commons 3.x. The idea is that there are multiple teams and leagues that all form a community as the players do not change much from league to league. So I want to create two types of groups. Team groups and League groups. Team groups with give players a place to converse over team matters. The league groups will be all inclusive and be the place where individual leagues will be created with related teams, players and games.

It all sounds good but I'm running into an gray area where I know it's possible in drupal 7, but haven't had to do this yet. What I am looking to achieve is how to create a relationship like so:

League Group > League Season (group content) > League Team (group content) > Players (users not already added to other League Teams)

That last part is what is eluding me. Within the League Team (group content) I am trying to add an entity reference to users that uses autocomplete. That part is easy, but how do I make sure that when I add multiple players, users already referenced to not show up again in the autocomplete?

Example:
If a player is selected in the same League Team type and I want to add another player, I click the Add Item button, get a new autocomplete field, and begin typing a new player. I do not want players that are either already associated with another League Team in the same League or already associated with the League Team being created.

Does anyone know how to make autocomplete filter out results already referenced by the same or other League Team types?

Comments

Quick question ... are you

jthorson's picture

Quick question ... are you attempting to do this within code (in a custom module), or with existing 'out-of-the-box' modules?

Currently I am trying to do

mcannon's picture

Currently I am trying to do this with "out-of-the-box" modules. I'm pretty good with PHP, but not really up to par when it comes to instant dynamic content supplied by AJAX which is why I am not sure about where to start with altering the autocomplete. I think if I can get past the hurdle of filtering out players already is use by other teams of a season, that will open the door for other aspects that I have planned out in a flowchart.

I am rebuilding a sports

hernani's picture

I am rebuilding a sports website from D6 to D7 (serbenfiquista.com) and I am creating a sports league module that will support:
- Clubs
- Teams
- Competition
- Matches
- Match Rosters
- Match Highlights
- Athletes
- Stats

The content model is similar to the one created by jthorson before but I have more entities in nodes because I want to support several things like revisioning.

Most of the entities are content types, other are specific entity types. Relations are maintained using entity reference and inline entity form module is used to allow creating rosters in masters. Some custom widgets are created in order to support a better UX when selecting teams, players, etc.

I will post more details and code soon, as it gets ready for primetime. Would love some comments!

Exact Match

mcannon's picture

This sounds exactly like what I am trying to build with the exception of doing it ontop of Commons. I've been wanting something like it for over two years. There was some movement on D6 which was never completed, and D7 support is still behind. With D8 right around the corner I would like to get this done for D7. So I'll over any help I can.

What's the difference between Clubs and Teams?

My general interpretation has

jthorson's picture

My general interpretation has been that the 'Club' is the container (representing the team's organizational body), while a 'Team' is each per-season instance of the Club.

Correct. Club would be

hernani's picture

Correct. Club would be Manchester United or Benfica, while team is manchester united 2012/2013 or Benfica 2012/2013. In my case I am also doing another relationship in teams, but that is optional. In matches you always reference teams.

Club: Benfica
Team : Benfica football team
Team: Benfica football team 2012/2013

I haven't yet tried/tested

mesch's picture

I haven't yet tried/tested the following, but believe it should work.

Create an entity reference view which only lists player entities that have not been referenced by any other team entity.

Then In your entity reference field settings, set the entity selection mode to "Views: filter by an entity reference view", and then select the view you just created.

First Attempt Failed

mcannon's picture

Hi MEsch,

I was already using an entity reference view in an attempt to do exactly what you are suggesting. I just gave it another try and the result is not getting better because of the complexity of the reference. It's not one to one, it's one to one to one (user > team > session).

Any suggestion on how to make the view filter based on a team referenced to/by a session?

I need to keep the players available for future sessions that will have it's own set of teams.

2nd Attempt, Success

mcannon's picture

Hi MEsch,

I dove into the view entity reference again last night and was able to iron out how to use the relationships with being able to step back all the way to the parent group. So now when I save a team with a player, that player is no longer available.

The next item up is how to make the autocomplete filter out new users before the save button is hit. Any thoughts?

Matt

I saw three posts and thought

Tran's picture

I saw three posts and thought someone was making big progress on a sports module for D7.
Then I was disappointed to see it was spam. And two responses to it.
Now I just added another response.
DOH!

I am using tournament module

abhinavutsc's picture

I am using tournament module in our site http://www.udzclan.org/ for urban terror events and may be you can add these features as requested in this post: https://drupal.org/node/2078483

Any progress on this?

elfwine's picture

I am also in search of good sports management module. Any progress on this?

Thanks.

Try