I get this notice message on view that shows average rating for current node.
Notice: Undefined property: stdClass::$nid in fivestar_views_value_display_handler() (line 1398 of ... \www\d7_test\sites\all\modules\fivestar\fivestar.module).
Some background:
I don't like the default method to display average score of comments proposed in http://drupal.org/node/234681 so I managed to attach view to node (using EVA module) which shows average score for current node.
I don't know if this is good or bad but it's better than hardcoding template file :)
Solution (at least in my case):
change
if (isset($columns->node_type)) {
$stars = variable_get('fivestar_stars_'. $columns->node_type, 5);
}
else {
$node_type = db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $columns->nid))->fetchField();
$stars = variable_get('fivestar_stars_'. (!isset($node_type) ? 'default' : $node_type), 5);
}
in fivestar_views_value_display_handler() function to
if (isset($columns->node_type)) {
$stars = variable_get('fivestar_stars_'. $columns->node_type, 5);
}
else {
if (isset($columns->nid)) {
$node_type = db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $columns->nid))->fetchField();
}
$stars = variable_get('fivestar_stars_'. (!isset($node_type) ? 'default' : $node_type), 5);
}
In my case $column variable has value
stdClass Object ( [votingapi_cache_node_percent_rating_average_value] => 66.6667 [node_created] => 1304006434 )
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | fivestar_views_notice-1146972.patch | 703 bytes | zambrey |
Comments
Comment #1
ericduran commentedIn drupal 7 you don't have to use the method describe over at http://drupal.org/node/234681
All you have to do is add a fivestar field to the comment and make sure the tag/axis is the same the node is using.
That being said this bug is really not related to that.
I'm perfectly fine with the change mention above. A patch would be great ;-)
Comment #2
zambrey commentedSo here is the patch.
It took me some time to learn Git but hopefully it will be okay.
Thanks for encouragement :)
Comment #3
OldAccount commentedThe patch worked for me, thanks!
Comment #4
james.elliott commentedThe patch is simple enough
Comment #5
ericduran commentedThanks for the patch and review.
This is now fixed
--
http://drupalcode.org/project/fivestar.git/commit/aa75ac44c7b0b4c1f38a37...
Comment #8
pcorbett commentedI may be missing something, but I don't see this patch as included in the latest 7.x-2.x-dev release or the alpha1.
Comment #9
ericduran commented@pcorbett because this is an old issue and that code isn't on the module any more.