9

I have a review content type that (node) references a product content type. I'm using fivestar ratings for overall rating and specific ratings. With fivestar I can make the product the "vote target".

One of the ratings is a "yes/no" type rating where I want to show the aggregate on the product node (x% of users rated yes).

I tried to use fivestar with a "1 point" rating where 1=yes, 0=no but the problem is that 0 votes are not saved at all, therefore always resulting in a 100% result.

I could probably use a "2 point" rating and then have a custom display formatter to do the math and translate it to the correct %.

Are there any other solutions? I can't use the rate module because I already use it for "thumbs up/down" ratings.

1

The Rate module allows one to attach multiple rate widgets to a content type. Create one rate widget for thumbs up/down and second for yes/no.

Drupal Commons Distribution with Commons Q&A includes both a Like and Points system in this manner...

enter image description here

When you add a second widget, choose to attach it to the same content type(s). enter image description here

1

In extends of Flags, you could use Rate. It should fit to your needs (Rate a node with Yes / No Flag and get its result into a percentage data)

0

I am working on a very similar issue and hit a brick wall with using Fivestar, Rate, Flag, etc. as well. I got here through google many months later because I was looking for the 'vote target' functionality of fivestar but the simplicity of a vote up / down widget for a Yelp style interface with a node and comments added as reviews.

I used the Vote Up/Down widget and followed the advice here from the module maintainer marvil07 on Drupal.org to render the widget in the comment form as opposed to within the node form:

  • Enable comments for the node type you want.
  • Add one vud_field field to the node type you want.
  • Set the vud_field field formatter to hidden.
  • Render the vote widget manually on the comment form(normally) and on the node type (with the readonly option).

This works well since the field is rendered as an AJAX widget and contains all the information it needs to record the vote against the correct node. My exact implementation of this worked like this with my Vote Up / Down field 'field_rating':

function MYTHEME_form_comment_form_alter(&$form, &$form_state) { 

  if ($form["#form_id"] == "comment_node_MY_YELP_KNOCKOFF_form") { 

    $node = node_load($form["#entity"]->nid);
    $field = field_view_value('node', $node, 'field_rating', $node->field_rating[$node->language][0]); 
    $vud_render = render($field);

    $form["voteupdown"] = array(
      '#markup' => $vud_render,
      '#weight' => 0,
    ); 

  }

}

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.