"log in to rate it" message for non connected user
julma - March 23, 2008 - 16:27
| Project: | Fivestar |
| Version: | 5.x-1.11 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
On youtube, only connected users can vote, and when a user is not connected he gets the java script message "Log in to rate".
Is it possible to have this behavior with five star ?
Thanks

#1
Youtube is still a good example of this feature.
#2
#3
#4
This behavior is possible, but can't really be implemented by default. The reason being it's possible to have multiple roles, and even if the user was logged in they still couldn't vote. So we can't make that message part of the default Fivestar install because it'd be inaccurate in a lot of cases.
Instead, what you can do is over ride the theme_fivestar_static_element() function in your template.php, to make it include this message for your particular site.
<?php
/**
* Display a static fivestar value as stars with a title and description.
*/
function [nameofyourtheme]_fivestar_static_element($value, $title = NULL, $description = NULL) {
$output .= '<div class="fivestar-static-form-item">';
$element = array(
'#type' => 'item',
'#title' => $title,
);
$output .= theme('form_element', $element, $value);
$output .= '<div class="description">'. t('Login or register to vote.') .'</div>';
$output .= '</div>';
return $output;
}
?>
#5
Is this possible in D6?
#6
+1 for D6 implementation.
#7
subscribe