I am creating a directory with reviews in D7 (7.8). I downloaded the Fivestar module and successfully integrated that into the comments field as I want each member who leaves a comment to be able to put in his or her own review - so far smooth sailing.

However, a couple things - These comment fields do not show up in Views - is this a bug? Am I not doing something correctly? None of my custom fields in comments show up in Views.

Ideally, what I would like to do is have people add a comment, rate it, and, in the node of the item being reviews, I somehow could average user comments and display them there.

Any thoughts on how to achieve that or if I am approaching Comments incorrectly in views?

Thanks,
Blue

Comments

ayesh’s picture

I think you need to add a "relationship" to Vote Results to make them available in Views.

Gastonia’s picture

It was a relationship issue, thanks - but to explain a little more, if anyone is actually having this problem you should start with the Comment views type. The relationships are created by default.

fidowu’s picture

I'm new to Drupal (v7). I have created a comment view type but not sure what to do next. On the subsequent page do I create an Relationship with Vote results to get the Average comment rating. Please help

rajmataj’s picture

Can you please explain how you used Views to show the Comment form? I am trying to create a block that could use the NID as an argument to then display the comment form for a node. I don't need to show the actual comments made, just the form. Any help would be really appreciated. Thanks!

one_orange_cat’s picture

The following code generates the comment form, and you can use it directly in your main view template file (e.g. views-view or views-view-unformatted - wherever you can access the NID in question) -

$build = drupal_get_form("comment_node_{$node->type}_form", (object) array('nid' => $node->nid));
print render($build);

If you do this and then want the user to be returned to your view after comment submission, you'll also need something like the following in a custom module:

// Make sure we are redirected back to the originating view page after submitting a comment
function MY_MODULE_form_comment_form_alter(&$form, &$form_state, $form_id) {
	if ($form_id == 'comment_node_CONTENT_TYPE_form') {
		$path = drupal_get_destination();
		$form['#action'] .= '?destination=' . $path['destination'];
	}
}