First i'd like to say truly amazing module, i really appreciate all the work that has been done on this module.
I'm having trouble setting up a view to just show my site's comments for products and the relevant fivestar rating posted with each.
I have followed the "Building Views with Fivestar and VotingAPI" example here: http://www.lullabot.com/videos/building-views-fivestar-and-votingapi however what i need is slightly different...
I would like to simply list all comments on node type: products and the associated fivestar rating that was submitted with that comment.
I have done everything i can think of to set up the relationshop and field correctly, however i must be doing something wrong- as it just shows all Ratings as 5 stars rather than the correct corresponding rating per comment.
I am not using the nodeComment module, I'm just using the built-in node rating via comments functionality.
Is there any advice or questions you could ask me to help me get this working?
any help would be greatly appreciated
Here is my view export:
$view = new view;
$view->name = 'comments_recent';
$view->description = 'Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'comments';
$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(
'nid' => array(
'id' => 'nid',
'table' => 'comments',
'field' => 'nid',
'label' => 'Node',
'required' => FALSE,
),
'votingapi_vote' => array(
'label' => 'Rating',
'required' => 0,
'votingapi' => array(
'value_type' => 'percent',
'tag' => 'vote',
),
'current_user' => 0,
'id' => 'votingapi_vote',
'table' => 'node',
'field' => 'votingapi_vote',
'relationship' => 'nid',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('fields', array(
'subject' => array(
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'label' => '',
'link_to_comment' => 1,
'relationship' => 'none',
),
'timestamp' => array(
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'label' => '',
'date_format' => 'time ago',
'custom_date_format' => '',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'timestamp' => array(
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'order' => 'DESC',
'granularity' => 'second',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status_extra' => array(
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'operator' => '=',
'value' => '',
'group' => 0,
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'relationship' => 'nid',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Reviews and Comments');
$handler->override_option('items_per_page', 5);
$handler->override_option('use_more', 1);
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
'type' => 'ul',
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('fields', array(
'title' => array(
'label' => 'For Product',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'nid',
'override' => array(
'button' => 'Use default',
),
),
'timestamp' => array(
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'label' => '',
'date_format' => 'time ago',
'custom_date_format' => '',
'relationship' => 'none',
),
'subject' => array(
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'label' => '',
'link_to_comment' => 1,
'relationship' => 'none',
),
'comment' => array(
'id' => 'comment',
'table' => 'comments',
'field' => 'comment',
'label' => '',
'relationship' => 'none',
),
'value_1' => array(
'label' => 'Rating',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'set_precision' => 0,
'precision' => '0',
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'appearance' => 'fivestar_views_value_display_handler',
'exclude' => 0,
'id' => 'value_1',
'table' => 'votingapi_vote',
'field' => 'value',
'relationship' => 'votingapi_vote',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', '1');
$handler->override_option('row_options', array(
'inline' => array(
'title' => 'title',
'timestamp' => 'timestamp',
),
'separator' => ' ',
));
$handler->override_option('path', 'reviews-and-comments/recent');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('block_description', 'Recent comments view');
$handler->override_option('block_caching', -1);
ps- I have renamed all my comments to "review or comment"s with stringOverride
| Comment | File | Size | Author |
|---|---|---|---|
| Edit-view-comments_recent---Amish-Hand-Crafted_1274911015284.jpg | 120.76 KB | SchwebDesign |
Comments
Comment #1
strings6 commentedI am having the same problem in the new dev version (6.x-2.x-dev). I have a View fueled by comments and when I add a relationship with the Comment: Votes (Votes cast by users on comments.) the view stops returning results if I require the relationship (I suspect this is the true bug-- each comment has a fivestar rating so I'm not sure why it stops returning results). If I do not require it, all the fivestar results show 0 stars.
If I try adding the relationship Node: Votes (Votes cast by users on nodes.) instead, and require the relationship, I do in fact still get my comments as a result in the view, but unfortunately every comment shows the fivestar rating of the first comment submitted. I suspect the person who posted this issue originally was using this method and was seeing all 5 stars on all comments because the first comment made on that node was rated as a 5.
I was planning to use the fivestar module on a current client's website, so if you know a solution I'm all ears. One of their requirements is to have a View showing 2 or 3 comments for a particular node, right on that node. Here is my exported view:
Comment #2
whiteph commentedSorry, Drupal 6 is end of life, and is no longer supported.