Paid affiliate advertisement

small module needed

fossle - November 2, 2009 - 18:34

On a baseball web site, we have a standings page that shows the Wins | Loss | Wins %

The Wins and Loss have to be added together and then divided by Wins to get the Win %

There will be over 100 teams, so we need a fast way to update the team scores each week.

There will be four or five divisions that need these scores displayed for just the teams in their divisions.

The info below was suggested by someone on drupal. We need this implemented. Please let us know time/cost to complete. If you have a better solution, we are open to this too.

Thank you,
Kim

****

Would it be too much work to make a settings page for a small custom module that just allows you to set wins and losses for each published team node?
You could simply query for a list of team nodes, and for each one, output a field to contain the wins and losses.
Your module could have no other purpose but to just collect this information on one page and then it would be available for you to calculate the % and spit it out wherever you want.

Here is a link which demonstrates how to make a module configuration page.
http://drupal.org/node/206761

Here is a rough idea of what your code might look like:

function teamwins_admin() {
$form = array();
$result=db_query('select nid, title from {node} n where status=1 and type="team" order by title asc');
while($n=db_fetch_object($result)){

$form['teamwins_'.$n->nid] = array(
'#type' => 'textfield',
'#title' => t('Wins for '.$n->title),
'#default_value' => variable_get('teamwins_'.$n->nid, 0),
'#size' => 2,
'#maxlength' => 2,
'#description' => t("The number of wins for ".$n->title),
'#required' => TRUE,
);

$form['teamlosses_'.$n->nid] = array(
'#type' => 'textfield',
'#title' => t('Losses for '.$n->title),
'#default_value' => variable_get('teamlosses_'.$n->nid, 0),
'#size' => 2,
'#maxlength' => 2,
'#description' => t("The number of losses for ".$n->title),
'#required' => TRUE,
);

}
return system_settings_form($form);
}
You could use a submit handler to add these values to your node's fields if they had a field to contain this information.

You may want to look at

mradcliffe - November 2, 2009 - 21:21

You may want to look at extending this instead, editview or editabefields, which may be easier to use.

+1 to mradcliffe

shenzhuxi - November 3, 2009 - 03:17

Yeah, use mradcliffe's suggestion with views for fast input, and also try Dynamic Field and Computed Field for the win rate.
I think you can do it by yourself.

Why I got "You are not authorized to post comments." when reply the main thread?

 
 

Drupal is a registered trademark of Dries Buytaert.