Like many others, I have found the video here extremely helpful:
http://www.lullabot.com/videocast/building-views-fivestar-and-votingapi
...as I'm trying to replicate the following functionality that is very similar to this artist site below....
http://www.daughtryofficial.com/music/album/daughtry
I simply have created a content type called "track", and built a view to list the fields within the track, and fivestar is enabled for this type.
If I follow the lullabot video, that's really for a different purpose - it's to display the average rating from all users for a node, and then they also include a field to show what your rating is for that node.
Let's say you haven't voted on it yet, and you decide to, or even if you decide you want to click the fivestar widget again for that node...what happens is the view will now show duplicate entries, because you may have voted on a track more than once, to it will show that track for each time you vote for it.
I know this is like trying to fit a square peg in a round whole for what I want, but my question is how to do I build a view that lists the tracks, but people can rate each track, without it displaying that node over and over each time a rating is added to that node?
I have been googling and desperately searching through drupal.org to the best of my ability for 2 days, and can't figure this one out.
If I should do this in PHP - that is fine, too....just PLEASE, SOMEONE, point me in the right direction on how to approach this the *right* way.
Comments
Comment #1
travis.anderson commentedEvery other post I have found on this subject, never gets responded to. This is my only resort, can someone slap me upside the head to let me know what I'm doing wrong?
Comment #2
quicksketchCan you export your view and attach it so we could take a look? Trimming it down to a minimum number of fields will make it easier for us to import.
Comment #3
travis.anderson commentedOk, this is my first time exporting a view, let me know how this looks.
$view = new view;
$view->name = 'music';
$view->description = '';
$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_vote' => array(
'label' => 'Individual votes',
'required' => 0,
'votingapi' => array(
'value_type' => 'percent',
'tag' => 'vote',
),
'current_user' => TRUE,
'id' => 'votingapi_vote',
'table' => 'node',
'field' => 'votingapi_vote',
'relationship' => 'none',
),
'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',
),
));
$handler->override_option('fields', array(
'field_artist_value' => array(
'label' => 'Artist',
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_artist_value',
'table' => 'node_data_field_artist',
'field' => 'field_artist_value',
'relationship' => 'none',
),
'title' => array(
'label' => 'Title',
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_ff_audio_fid' => array(
'label' => 'Play Song',
'link_to_node' => 0,
'label_type' => 'custom',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_ff_audio_fid',
'table' => 'node_data_field_ff_audio',
'field' => 'field_ff_audio_fid',
'relationship' => 'none',
),
'field_track_num_value' => array(
'label' => '',
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 1,
'id' => 'field_track_num_value',
'table' => 'node_data_field_track_num',
'field' => 'field_track_num_value',
'relationship' => 'none',
),
'value' => array(
'label' => 'Rate This Song',
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'appearance' => 'fivestar_views_widget_compact_handler',
'exclude' => 0,
'id' => 'value',
'table' => 'votingapi_vote',
'field' => 'value',
'relationship' => 'votingapi_vote',
),
'value_1' => array(
'label' => 'Average Rating',
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'appearance' => 'fivestar_views_value_display_handler',
'exclude' => 0,
'id' => 'value_1',
'table' => 'votingapi_cache',
'field' => 'value',
'relationship' => 'votingapi_cache',
),
));
$handler->override_option('sorts', array(
'field_track_num_value' => array(
'order' => 'ASC',
'delta' => -1,
'id' => 'field_track_num_value',
'table' => 'node_data_field_track_num',
'field' => 'field_track_num_value',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'track' => 'track',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'table');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'music');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
Comment #4
travis.anderson commentedanything else I can do to HELP someone HELP me? please....
Comment #5
mdowsett commentedI'd like to do the same ...and I'm even more challenged I think as I'm on a D5 site.
I'm using the View Bonus Pack and I was hoping to have a grid of images with the fivestar rating below each one so visitors could see many images and vote on each one without having to visit each node but it doesn't seem that that is possible.
You can either have a teaser view with the fivestar rating widget....but that's one long list rather than a grid...it may be my only choice tho.
Comment #6
mdowsett commentedit almost seems there needs to be a better support for the fivestar rating widget in Views as it's not listed in the list of fields when creating a view....
Comment #7
mcurry commentedsubscribe
Same here, can't see any Views or FiveStar integration when using Views 2; I'm on a slow connection so I can't watch the lullabot video :(
Still researching it...
Comment #8
mcurry commentedOk, it worked for me after following the steps shown in the lullabot screencast, referenced above.
Comment #9
dark_kz commentedwhat version of Fivestar u were using?
Comment #10
summit commentedSubscribe, would love to see a view using fivestar widget.
Anyone has a view using stories and fivestar? Please export it here for the community!
Thanks a lot in advance,
greetings, Martijn
Comment #11
lautaro.pastorini@gmail.com commentedHi, in order to solve the duplicated records problem, you must check the relationship of the view.
In the relationship you must put ONLY "Vote results", and no Vote.
I hope this can help you.
Comment #12
Anonymous (not verified) commentedHere's an odd one. I am creating a view which filters from two node-types. One of the node-types has a fivestar field - which I am displaying in the view. The other node does not have a fivestar field.
When the view is created a fivestar-field mysteriously gets displayed underneath the node-title of nodes that do not contain five-star fields... Obviously the value of them is zero. But setting the 'hide if empty' and 'treat 0 as empty' boxes does not make the five blank stars disappear for that node-type.
So in filters I have 'is one of' node-type1 and node-type2.
In fields I have :
Title (in both node-types)
Picture (in node-type1 only)
Vote results (in node-type1 only)
Picture2 (in node-type2 only)
Summary (in node-type2 only)
When the view displays fields from node-type1... all is dandy: I get Title, Picture and Vote Results.
When the view displays fields from node-type2... I get: Title, picture2, Vote Results and Summary.
Obviously, vote-results shuld not be displayed whena node of node-type2 is in the view - as it has no vote field.
Comment #13
whiteph commentedSorry, Drupal 6 is end of life, and is no longer supported.