When adding the fivestar into fields in Views 3.x, I cannot choose the widget appearance. By default, there are 5 choices, like Default appearance, Fivestar (display only) etc, but only the Default works

When I try to save the selection, it defaults back to the Default appearance, and the widget is shown in the form of text, like "Value: 80"

CommentFileSizeAuthor
#6 votingapi-views3.patch537 bytesjelenex

Comments

zualas’s picture

Currently using a workaround with a views PHP customfield to print fivestar fields:

<?php print theme('fivestar_static', $data->[field variable name here], 5) ?>
zualas’s picture

Status: Active » Closed (fixed)

Seems to be fixed in the latest version of Views

METZGERR’s picture

confirmed, value does not change (or be saved) with the dev version of views.
however the latest regular release works just fine.

7wonders’s picture

Still seems to be a problem but the workaround works. Any idea how to do the workaround using clickable widget with text option?

zualas’s picture

Not sure what your requirements are, but you could try theme('fivestar_widget'). Anyway, all widget options are listed in the functiom fivestar_theme() in fivestar.module file. Hope that helps.

jelenex’s picture

StatusFileSize
new537 bytes

Actually, the problem is in VotingAPI.
Here's a quick patch - tested with latest Views 3.x. Not sure if it doesn't break anything with View 2.x

summit’s picture

Project: Fivestar » Voting API
Version: 6.x-1.19 » 6.x-2.x-dev
Status: Closed (fixed) » Active

Hi,
Ported this issue to Voting Api, because the patch stated is within Voting Api, if this is not ok, sorry for my mistake.
Having this problem also. Thanks for going into this!

greetings,
Martijn

janis_lv’s picture

#6 does the trick.

ty

dagmar’s picture

Status: Active » Closed (duplicate)
Q2U’s picture

Posted by jelenex on August 27, 2010 at 6:06am > Actually, the problem is in VotingAPI. Here's a quick patch - tested with latest Views 3.x. Not sure if it doesn't break anything with View 2.x

For what it's worth: I (manually) applied jelenex's #6 patch to Voting API 6.x-2.3 (2009-Aug-15) votingapi_views_handler_field_value.inc. I then edited the view which was failing to save the "Fivestar (display only)" value correctly.

After I made my edit I reloaded my view and I selected the "Fivestar (display only)" value from the dropdown list and saved my changes at which time a boatload of errors was thrown (sorry I failed to make note of the errors) but the "Fivestar (display only)" value saved correctly! I then undid the changes I had made to votingapi_views_handler_field_value.inc. (I restored the original pre-edited version). I then reloded my view and the errors were no longer present and the "Fivestar (display only)" vaslue was still saved correctly (of course).

So if you have to run Voting API 6.x-2.3 (2009-Aug-15) you can (1) manually install the #6 patch, (2) make and save your "Fivestar (display only)" changes , and then (3) uninstall the patch (revert to the original version of votingapi_views_handler_field_value.inc.).

But after you are all done don't edit your "Fivestar (display only)" value setting again or you will (of course) revert to the same problem you started with.

beumont’s picture

I have installed the newest version of Views 6.x-3.x-dev and the 6.x-2.x-dev but its still not working. Can anyone please I need this :(

cptX’s picture

I verify that this problem is still here with 6.x-3.x-dev and 6.x-3.0-alpha3. With views 2 no problem at all. I'm using voting api 6.x-2.3 .

ymeiner’s picture

I do not know if this is my version but i cannot see the appearance select box on my website. drupal 7, views 3.

i used the following code in the tpl to create the widget:

    print theme('fivestar_static',array('rating'=>$row->{$field->field_alias},'widget'=>array('name'=>'basic','css'=>'/'.drupal_get_path('module','fivestar') . '/widgets/basic/basic.css'),'stars'=>'5'));
2noame’s picture

Same problem. Currently using Views 6.x-3.0 and Voting API 6.x-2.3. Refuses to save anything but "default appearance" in view when trying to make a new one, but displays all already set just fine.

Enrique.Ruiz’s picture

Version: 6.x-2.x-dev » 6.x-2.3
Status: Closed (duplicate) » Active

Same problem. Refuses to save anything but "default appearance" in view. Drupal 6.25. Views 6.x.3.0. Voting API 6.x-2.3. Fivestar 6.x-1.19.

Enrique.Ruiz’s picture

Many thanks ymeiner! I have the same problem. Where do you place this code in the tpl? Would it work with Drupal 6?

nanor’s picture

Version: 6.x-2.3 » 7.x-2.6

To use Fivestar module in Drupal 7 + Views 3 + Fivestar 7.x-2.0-alpha2 . Just add a field in your content type and from “Type of data to store.” drop down select fivestar field .

And in views just add rating/stars filed from your content type . No need for complex relationships.
You might not see the stars in the Live preview, but you will when you actually go to see your view page or block or whatever your view display is.

relaxpor’s picture

Excuse me, How could i fix by this solution?
i mean which file or where should i modify or append.

Thank ypu

torotil’s picture

Version: 7.x-2.6 » 6.x-2.x-dev
Status: Active » Fixed

As per comment #17 this seems to be handled via fields. So for 7.x-2.x there is nothing to do. The patch for 6.x-2.x has already been applied.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

charlie charles’s picture

Has this been fixed yet?

shabbir’s picture

Hi guys,

anyone still wondering how to do it with Drupal 7.24 + Five Star 7.x-2.0-alpha2 + Views 7.x-3.7, here is a work around,

copy the below code at the end of your fivestar.module file and save it, it will show the "Appearance" dropdown and you can select the
"five stars (with clickable text)" it is been tested at my end and it runs smoothly.

P.s. first try it in your non production site in your local machine and remove the php tag while copy pasting.

/**
 * VotingAPI Views formatter for displaying number of stars as text.
 */
function fivestar_views_value_text_handler($value, $field, $columns) {
  // Get the number of stars for this node type.
  $node_type = isset($columns->node_type) ? $columns->node_type : db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $columns->nid))->fetchField();
  $stars = variable_get('fivestar_stars_'. $node_type, 5);

  // If displaying a user's vote, always display a whole value.
  if ($field->table == 'votingapi_vote') {
    return ceil(($value / 100) * $stars);
  }
  else {
    if ($field->options['set_precision']) {
      return round(($value / 100) * $stars, $field->options['precision']);
    }
    return ($value / 100) * $stars;
  }
}

/**
 * VotingAPI Views formatter for displaying rating widget without text.
 */
function fivestar_views_widget_compact_handler($value, $field, $columns) {
  return fivestar_views_widget_handler($value, $field, $columns, FALSE);
}

/**
 * VotingAPI Views formatter for displaying rating widget with text.
 */
function fivestar_views_widget_normal_handler($value, $field, $columns) {
  return fivestar_views_widget_handler($value, $field, $columns, TRUE);
}

/**
 * Generic VotingAPI Views formatter for displaying rating widget.
 */
function fivestar_views_widget_handler($value, $field, $columns, $summary) {

  // If the user can't rate, use the display handler.
  if (!user_access('rate content')) {
    return fivestar_views_value_display_handler($value, $field, $columns);
  }

  if ($field->view->base_table == 'node') {

    // Find the VotingAPI tag for this field.
    foreach ($field->query->table_queue[$field->relationship]['join']->extra as $votingapi_setting) {
      if ($votingapi_setting['field'] == 'tag') {
        $tag = $votingapi_setting['value'];
      }
    }

    $content_type = 'node';
    $content_id = $columns->nid;
    $node_type = isset($columns->node_type) ? $columns->node_type : db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $columns->nid))->fetchField();

    $values = array(
      'user' => 0,
      'average' => 0,
      'count' => 0,
    );

    if ($field->table == 'votingapi_vote') {
      $values['user'] = $value;
    }

    if ($field->table == 'votingapi_cache') {
      $values['average'] = $value;
    }

    // Only pull in all the votes if we need to display the summary text.
    if ($summary) {
      $votes = fivestar_get_votes($content_type, $content_id, $tag);
      if ($field->table != 'votingapi_vote') {
        $values['user'] = isset($votes['user']['value']) ? $votes['user']['value'] : 0;
      }
      if ($field->table != 'votingapi_cache') {
        $values['average'] = isset($votes['average']['value']) ? $votes['average']['value'] : 0;
      }
      $values['count'] = isset($votes['count']['value']) ? $votes['count']['value'] : 0;
    }

    $settings = array(
      'stars' => variable_get('fivestar_stars_'. $node_type, 5),
      'allow_clear' => variable_get('fivestar_unvote_'. $node_type, FALSE),
      'style' => $field->table == 'votingapi_vote' ? 'user' : 'average',
      'text' => $summary ? variable_get('fivestar_text_'. $node_type, 'dual') : 'none',
      'content_type' => $content_type,
      'content_id' => $content_id,
      'tag' => $tag,
      'autosubmit' => TRUE,
      'title' => FALSE,
      'feedback_enable' => $summary ? variable_get('fivestar_feedback_'. $node_type, 1) : FALSE,
      'labels_enable' => $summary ? variable_get('fivestar_labels_enable_'. $node_type, 1) : FALSE,
      'labels' => $summary ? variable_get('fivestar_labels_'. $node_type, array()) : array(),
    );

    return drupal_get_form('fivestar_custom_widget', $values, $settings);
  }
  else {
    return theme('fivestar_static', $value, 5);
  }
}


shabbir’s picture

Issue summary: View changes

The reason why we are not able to see the drop down in the views is because the fivestar.module file does not have any function to show it for in the views (D6 has it). So in order to handle it in views we need to create views handler so that we can select it in the views.

Regards,
Shabbir