I am using the Voting Api and the Fivestar module so that users can vote the content. I tried to display the content based on highest ratings by creating a relationship in views as follows:
Content: vote results
Value-type: Points
Vote-tag: The rate widget vote tag (vote)
Aggregation-function: Number of votes / Average vote / Total score
Sort criteria in Views:
(Vote results) Vote results: Value (desc/asc)
The result is not sorted. The content is displayed randomly unsorted.
This might be because of an issue with the relationship handling in the voting api. See also the following links, this might be related issues:
- http://drupal.org/node/1823924
- http://drupal.org/node/1626634
The patch proposed by http://drupal.org/node/1823924 does not work with voting api 7.x-2.10.
Does anybody has an idea how to fix this sorting issue or interface issue between the voting api and views?
I just started with Drupal and have no idea how to further troubleshoot this issue.
Comments
Comment #1
torotil CreditAttribution: torotil commentedI've commited the patch from http://drupal.org/node/1823924 to 7.x-2.x: http://drupalcode.org/project/votingapi.git/commit/6d54f05 . The patch should also work against 2.10. Could you give it a try?
Comment #2
collier.matthew CreditAttribution: collier.matthew commentedHello, I'm having the same issue here. I just installed 7.x-2.10+8-dev. Unfortunately, the issue is not resolved for me.
I am trying to sort by number of votes.
I've tried any combination of settings, but currently I have:
Configure Relationship: Content: Vote results
Value Type: No filtering
Vote Tag: meetingtopictag
Aggregate Function: Number of votes
Anything more I can do to help?
Comment #3
collier.matthew CreditAttribution: collier.matthew commentedI think I mistakenly assumed that the patch you mentioned was already committed to the dev version.
I rolled back to version 2.10, then...
from: sites/all/modules/votingapi
wget http://drupalcode.org/project/votingapi.git/patch/6d54f05
patch -p0 --dry-run < 6d54f05
output:
patching file b/views/votingapi.views.inc
Hunk #1 FAILED at 273.
1 out of 1 hunk FAILED -- saving rejects to file b/views/votingapi.views.inc.rej
I've never installed a patch before. Am I doing something incorrectly?
Comment #4
torotil CreditAttribution: torotil commentedYes there is. Could you please give me the view export and the SQL that is executed?
Comment #5
torotil CreditAttribution: torotil commentedYou're almost doing it right: you need to pass -p1 instead of -p0.
Try:
curl http://drupalcode.org/project/votingapi.git/patch/6d54f05 | patch -p1
Comment #6
collier.matthew CreditAttribution: collier.matthew commentedThank you for that information. I successfully applied the patch with the correct arguments. Unfortunately, I observe no change to my sort order.
Here's my view export with the patch installed. Where do I go to get the SQL?
$view = new view();
$view->name = 'tax_term';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Tax Term';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '12';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Content: Vote results */
$handler->display->display_options['relationships']['votingapi_cache']['id'] = 'votingapi_cache';
$handler->display->display_options['relationships']['votingapi_cache']['table'] = 'node';
$handler->display->display_options['relationships']['votingapi_cache']['field'] = 'votingapi_cache';
$handler->display->display_options['relationships']['votingapi_cache']['votingapi'] = array(
'value_type' => '',
'tag' => 'meetingtopicvote',
'function' => 'count',
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Field: Content: Showcase Photo */
$handler->display->display_options['fields']['field_showcase_photo']['id'] = 'field_showcase_photo';
$handler->display->display_options['fields']['field_showcase_photo']['table'] = 'field_data_field_showcase_photo';
$handler->display->display_options['fields']['field_showcase_photo']['field'] = 'field_showcase_photo';
$handler->display->display_options['fields']['field_showcase_photo']['label'] = '';
$handler->display->display_options['fields']['field_showcase_photo']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_showcase_photo']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_showcase_photo']['settings'] = array(
'image_style' => 'medium-letterbox',
'image_link' => 'content',
);
/* Field: Content: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['label'] = '';
$handler->display->display_options['fields']['body']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['body']['type'] = 'text_summary_or_trimmed';
$handler->display->display_options['fields']['body']['settings'] = array(
'trim_length' => '600',
);
/* Field: Content: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['date_format'] = 'short';
/* Field: Vote results: Value */
$handler->display->display_options['fields']['value']['id'] = 'value';
$handler->display->display_options['fields']['value']['table'] = 'votingapi_cache';
$handler->display->display_options['fields']['value']['field'] = 'value';
$handler->display->display_options['fields']['value']['relationship'] = 'votingapi_cache';
$handler->display->display_options['fields']['value']['label'] = '';
$handler->display->display_options['fields']['value']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['value']['precision'] = '0';
$handler->display->display_options['fields']['value']['appearance'] = 'rate_views_widget';
/* Sort criterion: Vote results: Function */
$handler->display->display_options['sorts']['function']['id'] = 'function';
$handler->display->display_options['sorts']['function']['table'] = 'votingapi_cache';
$handler->display->display_options['sorts']['function']['field'] = 'function';
$handler->display->display_options['sorts']['function']['relationship'] = 'votingapi_cache';
$handler->display->display_options['sorts']['function']['order'] = 'DESC';
/* Contextual filter: Content: Has taxonomy term ID (with depth) */
$handler->display->display_options['arguments']['term_node_tid_depth']['id'] = 'term_node_tid_depth';
$handler->display->display_options['arguments']['term_node_tid_depth']['table'] = 'node';
$handler->display->display_options['arguments']['term_node_tid_depth']['field'] = 'term_node_tid_depth';
$handler->display->display_options['arguments']['term_node_tid_depth']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['term_node_tid_depth']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['term_node_tid_depth']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['term_node_tid_depth']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['term_node_tid_depth']['depth'] = '2';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
Comment #7
collier.matthew CreditAttribution: collier.matthew commentedHello, I managed to solve this issue. I determined that I was attempting to sort on the incorrect field. I also updated to 7.x-2.11 today.
I changed my sort from using:
(Vote results) Vote results: Function (desc)
To:
(Vote results) Vote results: Value (desc)
Comment #8
torotil CreditAttribution: torotil commentedNice to hear! Yes sorting by value should work better. I'm closing this as fixed. Perhaps you should also filter by function though.
Comment #10
jmary CreditAttribution: jmary commentedI have the issue whatever I use. My choices are not
(Vote results) Vote results: Function (desc)
and
(Vote results) Vote results: Value (desc)
but
Score (field_score:rating)
and
Score (field_score:target)
The view is :
and the SQL query is :
Comment #11
torotil CreditAttribution: torotil commented@jmary please don't post to already closed fields. Judging from your view and your query votingapi is not involved in your issue.
Comment #12
As If CreditAttribution: As If commentedBe sure to set your data filters correctly in the relationship. You will get multiple results if you don't.