We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Solspace Rating Problem

Development and Programming

s707's avatar
s707
1 posts
16 years ago
s707's avatar s707

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]

       
Arun S.'s avatar
Arun S.
792 posts
16 years ago
Arun S.'s avatar Arun S.

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}
       
s707's avatar
s707
1 posts
16 years ago
s707's avatar s707

Thanks, but it doesn’t work…

       
BC Team's avatar
BC Team
244 posts
16 years ago
BC Team's avatar BC Team

Looking at using the Rating Module and am searching for live examples but found this thread.

I think the code may need to be, i’m just guessing:

{if overall_count == ""}

OR

{if overall_count == "null"}

OR something like that - Did you get it to work?

       
Narthex's avatar
Narthex
83 posts
16 years ago
Narthex's avatar Narthex

The stats tag doesn’t seem to show at all if there is not any data. The following does work, though. Make sure it is not within any tags. It can stand on its own.



						
       
Yuri's avatar
Yuri
273 posts
15 years ago
Yuri's avatar Yuri

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.
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.