Closed (won't fix)
Project:
Voting API
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 May 2007 at 19:36 UTC
Updated:
11 Jan 2011 at 16:25 UTC
Jump to comment: Most recent file
Comments
Comment #1
sudeoo commentedDear AChamp,
try the following code in votingapi_views.inc in votingapi module.
replacing (line 212):
$query->add_where("%s %s %d", $field, $filter['operator'], $filter['value']);
with:
if (( $filter['operator'] == "<") || ( $filter['operator'] == "<=") ){
$query->add_where("$field is NULL OR %s %s %d", $field, $filter['operator'], $filter['value']);
} else {
$query->add_where("%s %s %d", $field, $filter['operator'], $filter['value']);
}
The patch (i donot have cvs installed and therefore, cannot create patch correctly using cvs diff and then this one is my first patches), therefore, somebody has to verify it before commiting to the CVS.
Comment #2
webastien commentedI had the same problem...
but line 212 is note the same (I use last 4.7 official release of votingapi).
An other tips to add "zero vote" to your views, is to call the "_votingapi_insert_cache_result" function like this :
_votingapi_insert_cache_result('node', $nid, 0, 'percent', 'rating', 'count');
_votingapi_insert_cache_result('node', $nid, 0, 'percent', 'rating', 'average');
It requires any modification of the module if you put this code in a hook, in my case, hook_noapi : $op = insert.
Comment #3
joshk commentedI'm curious whether or not eaton thinks this is a use-case that votingapi should handle: storing "zeros" in the cache table on node-creation. Currently, without something that works around this, combining votes and views to sort by rating is semi-broken out of the box because ranking nodes by sum(points) will put a node with -10 above a node with 0 (no votes), because at the sql level it's NULL, which always comes last.
Perhaps this is really an issue with the various voting modules though, in that they define the types of votes to be scored.
Comment #4
Scott Reynolds commentedI have worked my way around this issue by using a custom module that, on node insert, adds a cache record of 0 votes.
I would not suggest doing a votingapi_set_vote() but rather a direct insertion into the cache.
Comment #5
codenamerhubarb commentedOr replacing $query->add_where("%s %s %d", $field, $filter['operator'], $filter['value']); with the following worked for me...(using 5.x-1.5)
Check out http://downloadabook.net/ebooks/price for an example of filtering a list view by minimum average vote, using 0% as a possible value.
Comment #6
eaton commentedSupport for the 5.x branch of VotingAPI has ended with the release of Drupal 7 and the upcoming release of VotingAPI 7.x-2.4.