2

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)

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

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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