Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I want to create a Fivestar-Field which shows the average of 3 other ones.

Something like:

(Field A + Field B + Field C):3 = Field D

A,B and C are Fivestar-Fields which rate something and Field D is the average value out of the three.

I want the average to be showed via the star-widget of fivestar.

Is there a way to do that?

(I use Drupal 7)

share|improve this question
    
So fields A, B, and C are voting fields (from the Fivestar module) on separate content types? –  Boriana Feb 20 '13 at 22:08
    
They are voting fields –  Alex Feb 20 '13 at 22:36

1 Answer 1

Yes, You can able to do that using hook_node_presave

You can read three field values rating using $node and set using below command

$node->field_name_of_your_fourth_field[$node->language][0]['rating'] = $average_value;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.