Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is it possible to apply different voting criteria to different fivestar fields or other module depending voteapi?
Case 1
fivestar_field1 of content1:
Anonymous vote rollover : 5min
Registered user vote rollover : 5min
fivestar_field2 of content2
Anonymous vote rollover : 10min
Registered user vote rollover : 10min
Case 2
fivestar_field1 of content1
Anonymous vote rollover : 5min
Registered user vote rollover : 5min
advanced poll of all nodes:
Anonymous vote rollover : never
Registered user vote rollover : never
Is it possible to do like this?
Comments
Comment #1
hkvega01 CreditAttribution: hkvega01 commentedso sad need to hard code
function votingapi_select_votes($criteria = array(), $limit = 0) {
$window = -1;
if (empty($criteria['uid']) || $criteria['uid'] == 0) {
if (!empty($criteria['vote_source'])) {
if ($criteria['tag']=="heat") {
$window = 1800; //30 min
} else {
$window = variable_get('votingapi_anonymous_window', 86400);
}
}
} else {
if ($criteria['tag']=="heat") {
$window = 300; //5min
} else {
$window = variable_get('votingapi_user_window', -1);
}
}
if ($window >= 0) {
$criteria['timestamp'] = REQUEST_TIME - $window;
}
//var_dump($criteria);
$function = variable_get('votingapi_storage_module', 'votingapi') . '_votingapi_storage_select_votes';
return $function($criteria, $limit);
}
Comment #2
torotil CreditAttribution: torotil commentedHi,
As you found yourself: this is not possible in 2.x - Maybe using the field_api (with some fallbacks for non-fieldable entities) are the way to go in 3.x.
Thanks for documenting this here.