I use the following code:
{exp:rating:stats entry_id=”{entry_id}” precision = “2” theme=“default”}{overall_avg}{/exp:rating:stats}
The rates are shown as 5.00, however if an article does not have any rate - an empty place appears, but I would like it to be 0.00, how can I do it?
[Mod Edit: Moved to the Modules: Discussion and Questions forum]
First, Solspace has their own support forums. For matters like these, I’d suggest you post there. You’ll probably get more informed answers. The documentation is good too.
But this one, I can answer. 😊 What I would do in this instance is to use a conditional to test how many rating there are. If there are none, display “0.00”, otherwise show the average. So, something like this:
{exp:rating:stats entry_id="{entry_id}" precision="2" theme="default"}
{if overall_count == "0"}
0.00
{if:else}
{overall_avg}
{/if}
{/exp:rating:stats}
quote from Solspace forum on this issue:
Rating:Stats will return absolutely nothing if there’s no results. You’ll need to use the {if no_results}0{/if} conditional if you wish to display something in the event there’s no ratings for an entry. smile Keep in mind though, if you have the Rating:Stats loop inside of a Weblog:Entries loop, it will override the conditional and it wont work, so you’ll need to put the Rating:Stats code inside an embed instead.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.