I've installed the cck, voting api, and fivestar modules and followed the instructions in the fivestar docs about adding a custom cck field for reviews. The problem is that I have tried every php code I can find to place in the "Target Node ID:" section to generate the nid.. but nothing seems to work for me.

Can anyone help?

Comments

quicksketch’s picture

Could this be the same case as http://drupal.org/node/243012?

shadow_jh’s picture

I did see that post, but it doesn't seem to offer the same situation. Just to be safe, I did try the php code offered in the post to no effect.

quicksketch’s picture

Cool, just checking. What setup are you trying to use to create reviews? Could you describe how reviews are related to their parent nodes, and what code you've tried in the Target ID box.

shadow_jh’s picture

Sure, thanks for the help by the way :)

Im following the instructions laid out here under "Configuration as a CCK field / Advanced Rating":
http://drupal.org/handbook/modules/fivestar

Its this part that HORRIBLY vague:

The Node ID field is the most important field on the page
which determines exactly what node will receive the value of the rating. In a
realy simple case, you could just enter the value 10 to always rate on the same
node with nid = 10. Usually you'll need to enter PHP code to dynamically select
what node you want to rate.

here are a couple of the "solutions" that I have found in various threads:

<?php
  return $_GET['target'];
?>
<?php
if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1);
print $nodeid;
?>
shadow_jh’s picture

This is probably important information:
I couldn't get fivestar to work at all with views and the voting api using drupal 6.. So I went with version 5 and all of the latest module versions built for drupal 5.

Another important observation:
Also, if I enable fivestar on the parent node itself as well as for the cck field, I can vote on the node from the front end, then edit the original review (parent node) and the cck field fivestar rating will then register.

quicksketch’s picture

Yeah Drupal 6 VotingAPI/Views isn't *quite* ready for primetime. Give them 2-3 weeks and things will be chipper. If you've got a decent timeline you should stick with 6, better start on 6 than have to upgrade later :P

I don't think the suggestions to use "print" will work, you should always be returning.

  return $_GET['target'];

This should work as long as you were accessing the node form like this:
node/add/review?target=20

Of course if $_GET['target'] is empty that's not going to work. So if the user goes back and edits the node the review rating won't be updated on the target node.

shadow_jh’s picture

Yeah I would think that would work too... but it doesn't :{

Im not even doing anything custom, Im just doing what is in the manual. If this feature is no longer supported it should be removed. Even the "simple" example of placing a specific node id in the NID field doesn't work! Im starting to think that the field itself is broken...

quicksketch’s picture

I'm pretty sure the feature works. Please don't tell me to take out a feature just because it's being troublesome. I could just as easily tell you you to not to use the module because you can't figure it out.

Here's a video demonstrating using $_GET['target'] approach. The node on the front page (129) has a rating of 5 stars, I set it to 1 star with the normal widget, then submit a "link" node type that reviews that node and sets it back to 5 stars. Please excuse all the random fields and debugging information everywhere, it's my dev site.

http://quicksketch.org/sites/quicksketch.org/files/Fivestar-target.mov

shadow_jh’s picture

No need to get defensive.

The five star rating is being saved in the node it just isn't being sent to the voting api table. So yes, once saving the node, the rating does display on the user end as displayed in your video. This is just as described in the docs:

The value is
saved in the node (so when you edit it it is still there), but no vote is
registered in VotingAPI without the Node ID field filled out.

So while fivestar itself is functioning properly, it isn't successfully passing the vote to the votingapi when used with the cck field.

quicksketch’s picture

The node on the front page (129) has a rating of 5 stars, I set it to 1 star with the normal widget, then submit a "link" node type that reviews that node and sets it back to 5 stars.

I review one node with another one. The new node reviews the first one and affects it's rating.

quicksketch’s picture

Status: Active » Closed (fixed)

The Fivestar CCK implementation has a new approach in the 1.13 version of the module, which is much more reliable. It integrates with nodereference fields directly, so you don't have to use PHP code any longer. Please open a new request for questions about the new implementation, I'm closing this issue as it no longer applies to the new version.