Listing top “x” articles with their rating displayed…
Posted: 03 February 2008 04:36 PM   [ Ignore ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

I have no idea why this is so hard…

This is how I want it displayed:

4.5 Article1 name
4.0 Article2 name
3.5 Article3 name

etc… etc…

Now, if I use {exp:rating:rankings} I can’t seem to get the rating to display. Is there a variable that works for this?

Alternatively, if I use {exp:rating:stats} nothing shows up at all unless I put entry_id="{entry_id}” into the tag but because this is my index page, and I don’t want it to be just 1 entry, I get a PHP error (which makes sense).

Oh, and P.S. yes, {exp:rating:entries} works but it will show the same post multiple times. I am looking for the top posts, in order of rating and that’s it.

Would someone mind sharing how I can achieve what I want here?

Thanks!

Profile
 
 
Posted: 04 February 2008 07:42 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Hi Travis,

I apologize for the documentation…
This coding below should be what you’re after: smile

{exp:rating:rankings}

<div>{exp:rating:stats entry_id="{entry_id}" theme="default" precision="1" thousands="," fractions="."}{avg_rating}{/exp:rating:stats} {title}</div>

{/exp:rating:rankings}

 Signature 
Profile
 
 
Posted: 04 February 2008 09:31 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

Hey man,

Thanks for the reply.

We’re almost there.

If I use that code, I get the following PHP error (it goes away if I remove the entry_id="{entry_id}" by the way):

NoticeUndefined indexsum_1 in /var/www/www.domain.com/public_html/system/modules/rating/mod.rating.php on line 3500

Is that something to worry about or should I just hide notice errors in PHP?

Profile
 
 
Posted: 04 February 2008 09:34 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

No, I wouldn’t hide the PHP errors… it could result in some other scripts not working properly wink

Is sum_1 or 1 a custom field in your Ratings Module?

 Signature 
Profile
 
 
Posted: 04 February 2008 09:42 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

Nope, the only field is “rating”.

Cheers,

Profile
 
 
Posted: 04 February 2008 09:46 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Which version of Rating do you have installed? Have you upgraded recently?

Also, if you don’t have any live data (only test data) for the Ratings Module, the easiest way to fix would probably be De-Installing the Module, re-uploading the files, then Re-Installing

 Signature 
Profile
 
 
Posted: 04 February 2008 10:07 AM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

The latest version is the only version I have ever had installed. Just purchased it 2 days ago.

I don’t have any live data, so I will try removing and installing it again, and let you know if that fixes the problem.

Profile
 
 
Posted: 04 February 2008 10:11 AM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

Scratch that.

When I installed it, I removed the “review” field since all I wanted was the rating. I did not however, change the field order on “rating” back to 1 so it was still looking for a field in #1 position. You might want to add a catch in there since field order shouldn’t really matter if there is only 1 field wink

Profile
 
 
Posted: 04 February 2008 10:24 AM   [ Ignore ]   [ # 8 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Haha, yeah, sounds a little clunky to me (but then again, I’m not a developer and there could have been a good reason for it.... or not) LOL wink

I’ll will document this smile

Thanks for the sharp eye… so it’s all fixed now? wink

 Signature 
Profile
 
 
Posted: 04 February 2008 10:26 AM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

New problem…

It is working… let me say first, I just can’t seem to get the ordering working right.

Here’s my code (I am using {exp:weblog:entries} because I need to use {related_entries id=""} if there is another way, I am all ears!)

<ul>
 
{exp:weblog:entries weblog="{my_weblog}" limit="8" disable="member_data|trackbacks"}
 
 {exp
:rating:rankings limit="1" orderby="rating" sort="desc"}

 
<li>
  
{exp:rating:stats entry_id="{entry_id}" form_name="beer" theme="default" precision="1" fractions="."}
   {avg_rating}
  {
/exp:rating:stats} <a href="/beer/{url_title}">{title}</aby
  {related_entries id
="brewery"}
  
<class="none" href="/brewery/{exp:urlsafe}{name}{/exp:urlsafe}">{name}</a>
  
{/related_entries}</li>

 
{/exp:rating:rankings}
 
 {
/exp:weblog:entries} 
 
</ul>

The listings are displayed like so:

Cream Ale by Sleeman
4.0 Coopers Cold by Coopers
3.5 Rickard’s White by Rickard’s
4.0 Steam Whistle by Steam Whistle

2 problems.

1) The first entry, with no rating at all is shown.
2) They are most definitely not in order wink

Any ideas?

Thanks man!

Profile
 
 
Posted: 04 February 2008 10:29 AM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Put the orderby="rating" sort="desc” parameters on the Rating:Stats loop smile

 Signature 
Profile
 
 
Posted: 04 February 2008 10:41 AM   [ Ignore ]   [ # 11 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

It’s weird… that doesn’t affect order at all.

The only time I can get the order to be changed is via the {exp:weblog:entries} tag, but I can’t order by rating in that tag so I am kind of stuck…

Profile
 
 
Posted: 04 February 2008 10:44 AM   [ Ignore ]   [ # 12 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

It orders correctly without the Weblog Entries loop though right?

 Signature 
Profile
 
 
Posted: 05 February 2008 02:33 PM   [ Ignore ]   [ # 13 ]
Newbie
Rank
Total Posts:  9
Joined  2008-02-02

Turns out, if I change the order of the tags to:

{exp:rating:rankings}
{exp:weblog:entries}

Everything works like it should.

Thanks man!

Profile
 
 
Posted: 29 August 2008 11:02 AM   [ Ignore ]   [ # 14 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Travis,

Your initial issuehere (field order in CP) should now be corrected in the release of Rating 2.2.0, now available for download. smile

 Signature 
Profile