I followed Nate Haug's excellent video tutorial on using Views, voting API and Fivestar here:

http://www.lullabot.com/videocast/building-views-fivestar-and-votingapi

Everything seems to work well while I am logged in, but when I log out and visit the page as an anonymous user, every vote is shown. The votes are grouped together by the title, and the order seems to be sorted in descending order by average value correctly, but instead of just showing just the average, every vote is shown. This seems to be the same whether I use "Voting Results" or "Individual Votes" relationship.

I am using:
Voting API 6.x-2.0-rc1
Views 6.x-2.1
Fivestar 6.x-1.13

Also, instead of voting on story content like the tutorial, I am using a simple CCK content type with little more than a title and body.

Any ideas how I can limit the View to list just one of each piece of content?

Thanks,

Chris

Comments

chrisindallas’s picture

Category: bug » support

One change from above, after I played with this some more, it seems like it only happens when I use a "Individual Votes" relationship. Everything works fine whether I am logged in or not with the "Voting Results" relationship. Am I correct to assume that I can use Views to list all the content of a certain type and allow voting from the Views page without clicking into the node and vote there? Or is Views only useful for displaying the results?

travis.anderson’s picture

Priority: Normal » Critical

Was this ever solved? I am hitting the same problem, and trying to go live with a website today! Driving me crazy. Keeps showing duplicate results, and I followed that Lullabot video exactly.

I like the way he asked the question better...exactly my problem. CAN ANYONE HELP?

travis.anderson’s picture

Am I posting this in the wrong spot? Where would be a better spot to get an immediate answer on this issue?

travis.anderson’s picture

Bump

travis.anderson’s picture

apparently i've stumped all of the drupal rockstars around the world.

travis.anderson’s picture

more accurately, I suppose chris did.

chrisindallas’s picture

Hi Travis, no I don't think I did. I wound up using the Voting API and Fivestar a different way in the end.

Good luck, Chris

travis.anderson’s picture

Chris - So did you end up solving the problem? Do you know how I would solve this issue?

chrisindallas’s picture

It's been a while since I worked through it. Basically, from what I remembered, I simplified what all I wanted the view to do. Here is an export of my view, if it will help:

/**
* Implementation of hook_views_default_views().
*/
function foo_views_default_views() {
$view = new view;
$view->name = 'prototype_tour_tab1';
$view->description = 'Prototype Tour Votes';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'votingapi_cache' => array(
'label' => 'Voting results',
'required' => 0,
'votingapi' => array(
'value_type' => 'percent',
'tag' => 'vote',
'function' => 'average',
),
'id' => 'votingapi_cache',
'table' => 'node',
'field' => 'votingapi_cache',
'relationship' => 'none',
),
'votingapi_vote' => array(
'label' => 'My Rating',
'required' => 0,
'votingapi' => array(
'value_type' => 'percent',
'tag' => 'vote',
),
'current_user' => TRUE,
'id' => 'votingapi_vote',
'table' => 'node',
'field' => 'votingapi_vote',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'label' => 'Tour Name',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'value' => array(
'label' => 'Average Rating',
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'appearance' => 'fivestar_views_value_display_handler',
'exclude' => 0,
'id' => 'value',
'table' => 'votingapi_cache',
'field' => 'value',
'relationship' => 'votingapi_cache',
'override' => array(
'button' => 'Override',
),
),
'value_1' => array(
'label' => 'My Rating',
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'appearance' => 'fivestar_views_widget_normal_handler',
'exclude' => 0,
'id' => 'value_1',
'table' => 'votingapi_vote',
'field' => 'value',
'relationship' => 'votingapi_vote',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('sorts', array(
'value' => array(
'order' => 'DESC',
'id' => 'value',
'table' => 'votingapi_cache',
'field' => 'value',
'relationship' => 'votingapi_cache',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'prototype_tour' => 'prototype_tour',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'status' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'Prototype Tour Voting');
$handler->override_option('header', '

Prototype Tours - Les Brandt

You may have already heard the news about Prototype Tours – You get to have a say in what tours we present! There are so many great prototype things to see in the area we just wanted you to have a say in which ones we go after.

Give each of the possible prototype tours below a rating from 1 to 5 stars. More information about the tour can be found by clicking on the tour name.

Hurry and vote today! Voting ends December 31, 2008.

The results can be found here');
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 1);
$handler->override_option('footer', 'If you have an idea for a prototype tour, please send it to chris@railroadmodelers.com, and I will add it to the voting.');
$handler->override_option('footer_format', '1');
$handler->override_option('footer_empty', 0);
$handler->override_option('items_per_page', 20);
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'list');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('style_plugin', 'default');
$handler->override_option('style_options', NULL);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'teaser' => 1,
'links' => 0,
'comments' => 0,
));
$handler->override_option('path', 'prototype-tour/tab1');
$handler->override_option('menu', array(
'type' => 'default tab',
'title' => 'Prototpe Tour Voting',
'description' => '',
'weight' => '0',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'normal',
'title' => 'prototype-tour',
'description' => '',
'weight' => '0',
));
$views[$view->name] = $view;

return $views;
}

ChrisRut’s picture

Status: Active » Closed (duplicate)
andrew smith’s picture

did you tick "restrict to current user"?