Fivestar can't be added to comments. There is a nodecomment module and an issue about using fivestar with that, but the nodecomment module is problematic if you don't want all comments to be nodes ( http://drupal.org/node/166064 ). So I'm looking at other solutions. I've written up a rough plan of attack for doing it on my site. I haven't actually tried this yet, so no guarantee it will work.

Create a node type "Review"
- Fields:
- Title
- Body
- Review of (integer / hidden) - This is a reference to the node ID of the node that is being reviewed. (Maybe use nodereference field instead?)
- Enable fivestar

Create a view
- Full nodes
- Argument: "review of"

Create node types that can be reviewed
- Enable fivestar
- Add the view (theming)
- Add link to add a review (theming)

On clicking link to add review populate "review of" field (prepopulate module)
On saving review add votes to reviewed node (actions module(?) or custom code)
On deleting review, remove votes from reviewed node (actions module(?) or custom code)

Any thoughts?

Thanks,

Michelle

Comments

michelle’s picture

This is coming along pretty well. The main thing I'm stuck on is how to get the rating on the review to apply to the item being reviewed in addition to (not instead of) the review node. I've been reading http://drupal.org/node/148150#comment-253615 and it looks like the problem isn't quite resolved there. Plus, I'm not using nodecomment. I have the node being reviewed's ID in a field on the review, but that isn't saved until the node is saved, so I don't know how to retrieve it from the fivestar CCK field's code. Plus, I still want the rating to show up on the review.

If someone could help me past this tricky bit, I think I can handle the rest and can write up something on doing it.

Thanks,

Michelle

michelle’s picture

Ok, I've made more progress on this. I have a CCK integer field, "nid", to store the target node and put "return $node->field_nid[0][value];" as the PHP code for my CCK fivestar field. In order to make this work, I had to change the drupal_eval to just eval in fivestar_field.inc because the $node object is not in scope with drupal_eval. I hate to have a hacked module so if there's anyway that change could be made permanent, that would be great. :)

The problem I'm currently struggling with is how to make it so users can only enter one review per node. I need to put in a check to see if a review by that user exists. I'm guessing this would be best done with a SQL statement? Unless someone has a better idea? That would work as far as whether to print the "add a review" link, but what do I do if someone types the add URL in directly? Woudl I need to put a check in the add form as well? Any ideas?

Thanks,

Michelle

quicksketch’s picture

To avoid the drupal_eval problem, try using the arg() functions to get the current node:

if (arg(0) == 'node' && is_numeric(arg(1)) {
  $node = node_load(arg(1));
}

For limiting the number of reviews... you'll need to do some custom hook_form_altering I think.

michelle’s picture

If anyone is interested, I put up a tutorial for this:

http://shellmultimedia.com/tutorials/rate-review-one-step

It doesn't take into account Quicksketch's advice as I just saw it now. Will give that a try.

Michelle

michelle’s picture

I was just going to try your suggestion and I realized it won't work. When you're entering a review, it isn't saved, yet, so node_load() won't be able to load it.

Thanks, though,

Michelle

quicksketch’s picture

Status: Active » Closed (fixed)