How to display the average rating of a node as stars in a view? The users on my website can rate an article with the Fivestar module while they comment. I'd like to create a view with the 5 articles that have the highest average score.

I've nearly been able to achieve what I want with a 'Vote results' relationship and a 'Vote results: Value' field. The problem is that the average score is displayed as a number, but I'd rather like it to be shown as stars. I achieved this in the past without custom coding (thanks to a deleted video that was situated here), but I forgot how to do it.

Can you help?
This is what I came up with:

Create a Views template for this specific field and put it in your theme (or module if you have Views templates already there and enabled via the Views api hook).

In my case it was called views-view-field--top-content--page-1--value.tpl.php for just the included and now enabled top content View.

In there, do the following:

&lt;?php
  $data = $row-&gt;{$field-&gt;field_alias};
  $path = drupal_get_path('module', 'fivestar');
  print theme('fivestar_static', array('rating' =&gt; $data, 'widget' =&gt; array('name' =&gt; 'basic', 'css' =&gt; $path . '/widgets/basic/basic.css')));
?&gt;


And if all is well in the world of copy and paste, you should now have a View with basic stars displayed instead of the number.  If you don't like the basic stars, just look in the widgets directory and you can take your pick of any of the other styles there.