hi
when i add a fivestar cck field on a content type on a fresh drupal 7 installation i can't set the destination node (i created a node reference field with the references module: http://drupal.org/project/references)
if i set the php code in this way
return $node->field_myfield[0]['nid'];
the php code is not saved and i receive always this error
No potential target fields are available for the xxxxxxxxx bundle. Create a node reference field in this bundle to make it easier to assign a vote to a node.

CommentFileSizeAuthor
#3 target_version-1056046-3.patch1.42 KBmdixoncm

Comments

josh@pixael.com’s picture

Status: Active » Needs review

i solved this issue changing the line from 47 to 55 of fivestar.field.inc in this way

  if (module_exists('node_reference')) {
    $fields = field_info_fields();
    foreach ($fields as $field_name => $content_field) {
      // Make sure that this field exists for this type.
      if ($content_field['type'] == 'node_reference' && $content_field['bundles']['node'][0] == $field['bundles']['node'][0]) {
        $dynamic_options[$content_field['field_name']] = t('Node reference: @field', array('@field' => $content_field['field_name']));
      }
    }
  }

generalconsensus’s picture

When I perform that I get the error:

"Notice: Undefined offset: 0 in fivestar_field_formatter_view() (line 284"

mdixoncm’s picture

StatusFileSize
new1.42 KB

Comment #1 nearly worked for me, although there was an issue when using with a nodereference field that had been used on multiple content types.

I've had a pop at fixing this in a generic way, patch attached.

tresero’s picture

Confirm #2, this patch doesn' t work.

also, Fatal error: Unsupported operand types in xxx/drupal-7.0/includes/theme.inc on line 817

ericduran’s picture

Status: Needs review » Needs work

Based on the preview comment.

magda_’s picture

Subscribing.
This is a mayor problem for me, any solutions in sight?

ericduran’s picture

Assigned: Unassigned » ericduran

Ok, this is a big priority item. Working on this now.

cfbauer’s picture

Subscribing

agence web coheractio’s picture

Subscribing

ericduran’s picture

Closing #1132044: PHP target doesn't work as a duplicate of this issue. Also that issue has a patch attached to it.

ericduran’s picture

Status: Needs work » Fixed

Thanks for everyones patient.

This has been fixed in the latest master branch, It should be available in the next dev release, Usually 12 hours.
Commit http://drupal.org/commitlog/commit/2490/ee4fbd611396efc9e995ce9d0ddd061e...

ericduran’s picture

Oh almost forgot, If you're using a php code for the ratings you will now have to use $entity instead of $node. The code is slowly being abstracted out to support any entity not just node.

OldAccount’s picture

Can you please share more info on how you set up the node reference field? I want to add Fivestar ratings to the comments section for my custom content type. I have the References module installed and added a Node Reference field to the Comment fields but am not sure it's set up right because it still says "No potential target fields are available for the comment_node_product bundle. Create a node reference field in this bundle to make it easier to assign a vote to a node."

So I think I'm missing a step or something, I'd love some more clarification on how you got this to work. Thanks!

ericduran’s picture

@lrobeson, if you're using the fivestar field on a comment, you do not need to use a node reference. There will be an option called parent node which will automatically target the node you're commenting on.

The node reference field is for when you want to do more complicated rating systems.

I'll take some time to update the docs for the drupal 7. Maybe even shoot a video. I want to wait till the module is completely ready that way we can have extremely good docs.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

elly’s picture

Re-opening this, maybe not wisely as this might just be a support request...

I'm working off the 7.x-2.x-dev release from May 19 that's on the module page. What should I see when I am adding a fivestar field that needs to target another node?

I have a 'review' content type with a node reference field, and the behavior I expect is that when I add a fivestar field to my review type, under 'Voting Target' I should be able to choose the node reference field from the pulldown, but it just says 'none' in the pulldown.

Am I thinking about this wrong? Should I use PHP as described by the original poster in this thread? Or is this still not working?

elly’s picture

Status: Closed (fixed) » Active
elly’s picture

Status: Active » Closed (fixed)

Oho, nevermind, I had the wrong version installed in my sandbox. Carry on.

pcorbett’s picture

Category: bug » support
Priority: Critical » Normal
Status: Closed (fixed) » Active

I didn't want to create an entire new issue, so I'll re-open this one for a question.

I see there is target code in the 7.x-2.x branch, but I don't see where I can actually set a target/destination node. Basically, I'm attempting to create a review node with fivestar cck fields with a node reference (using the Entity Reference module) to another content type that is to be reviewed. I'm at the stage where I've got a view listing all scores based on each fivestar field tag. At this point, it's pulling data, but there are duplicates (likely due to the fact that two people reviewed the same piece of content -- which is desired).

There's a lot of documentation on multi-access rating systems, but all for 6.x or seemingly for a 7.x-2.x branch code that no longer is being utilized by the module?

Suggestions for how to properly do this?

pcorbett’s picture

Okay, I'm hoping this is just a documentation thing, but I followed http://drupal.org/node/1308114 and it seems that the only way to get a target option on a fivestar field is to add the field in the "comment fields" area of a content type versus the "manage fields" area. Is this correct? If so, it looks like then I'll need to install a different node reference module other than Entity Reference. Does this make sense?

pcorbett’s picture

Status: Active » Closed (fixed)

Closing this, I'll update the docs, but as it stands now the Entity Reference module isn't compatible with Fivestar but the References module is and I am able to specify a target on the normal Fivestar field in the Manage Fields area. Closing.

kolafson’s picture

The references module appears to be nearing end of life. Quote from the project page:

"References will most probably be deprecated in the near future in favor of Entity Reference, which should probably be considered first on fresh D7 projects. Another, more radical, alternative would be the Relation module."

It looks like Entity Reference is the preferred method now. As a result, I am unsure how to move forward with a review site I am working on.

My options at the moment appear to be:

Option 1) Add fields to comments to make them better for reviews, but then I lose normal comment functionality which I also want.

Option 2) Go ahead with a separate Review content type and use the references module for now. This might mean serious problems in the future if it is no longer supported

bsandor’s picture

For Entity Reference module see http://drupal.org/node/1488914