I have expanded the functionality of Fivestar in follow up of the recursive comment rating: #1916068: Add the ability to rate parent comments (recursively).
This feature adds an extra widget that not only displays the average rating that was given by its direct children but also shows its raw score that it gave to its parent. This way you can always see the actual score you gave on a parent comment and still see the average score users gave your score trough child comments.
Warning
This feature is not implemented the Drupal way. Normally one would submit this as a new module that simply extends the functionality of Fivestar. However, while most of Fivestar nicely uses Drupal's hook system to extend upon, some parts of the code simply do not and there is no (easy) way of breaking into the process.
The problem for me lies mainly in the fivestar.field.inc file, in the function fivestar_field_formatter_view(). In that function you will find this statement:
// Determine if we are going to display stars, rating or percentage.
$formatter = $display['type'];
if ($formatter == 'fivestar_formatter_percentage' || $formatter == 'fivestar_formatter_rating' || $formatter == 'fivestar_formatter_dualview') {
$element[0]['user'] = array(
'#theme' => $formatter,
'#instance_settings' => $instance['settings'],
'#display_settings' => $settings,
'#item' => $values,
);
// No stars to display. Our work here is done.
return $element;
}
This is a hard control structure that you cannot break into when inhering from this module, making it impossible to alter how a custom widget, delivered by a third-party module, would render. You will have to alter this statement, as you can see with the third condition of the "if" expression.
| Comment | File | Size | Author |
|---|---|---|---|
| 0001-Added-first-version-of-DualView-widget-for-Fivestar.patch | 4.3 KB | Timusan |
Comments
Comment #1
Timusan commented