1

configuration Drupal 7.7, FiveStar 2.x-dev, References module, Unique field.

  1. I have node value of Story tale
  2. Every user can write an Review and rate each story tale with multiaxis fivestar like: Idea, Grammar, etc. configures as rating references.
  3. Every user can create only one review per each story tale (unique field module).
  4. Rating is available when User create a Review node (so not ajax).

I can attach average rate of each one from multiaxis like Average Grammar, Average Idea etc for story tale by views.

What I can't do is: how to compute average of all multiaxis values it menas create one number computed from rating of Grammar + Ideas.

I tried create a Fivestar field for overall (average value). Then I created Computed field which compute overall value of review.

$overall = ($entity->field_style[$entity->language][0]['rating'] + $entity->field_rate[$entity->language][0]['rating'])/2;
$entity_field[0]['value'] = $overall/10;
$entity->field_overall[$entity->language][0]['rating'] = $overall;

Well Problem is that In field_overall is stored requested value, but VotingApi don't register this change created by computed field and it count 0 as stored value.

So. 1. Problem is that fivestar store this value before computed field compute overall rating 2. Or problem is, that fivestar is reading value not from $entity->field_overall but from other value.

  • do you know how to do it eventually? If so, can you answer how ? – Refineo Apr 26 '12 at 10:19
2

The easiest thing to do would be to set the value yourself with either hook_entity_insert/update or in a custom submit handler to the form.

The values are stored in the fields tables and not voting API when you use the five star with fields.

  • Thanks for idea. I know that better is to create a custom module, but I'm looking for "clickable" solution – Stano Aug 18 '11 at 6:03
  • @Stano What you tried above in nowhere near clickable. It's better to put code in a module than to store it in the DB. – googletorp Aug 18 '11 at 20:45

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.