Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Stars rating / Post rating plugin - get the average post-vote number at the end
Avatar
Gomlers
Member
Free Members
sp_UserOfflineSmall Offline
Mar 15, 2013 - 10:26 pm

I have installed the post rating plugin, and against all odds - I've managed to make a cool little list at the forum footer that shows the 10 most rated posts. I don't know if this is the best way of showing the list, but that was all I could do.

Please come with input on the best way of using the plugin :)

I have used this tag in in spFoot.php:

sp_rating_most_rated_posts_tag($limit=10, $forum=true, $user=true, $postdate=true, $listtags=true, $forumids=0, $count=true)

I got this result, by doing a little bit css:

Image Enlarger

Now, at the end of all those lines, I would like to show the average vote number. The first line, would e.g look like this:

I forumet: Skravleforumet, emne: Testnavn på tema: av Username (rangert 1 ganger), average votes: 4,7

Is that possible? And in so case - what should I put at the end of the php line?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 15, 2013 - 10:43 pm

I assume you have seen:  http://codex.simple-press.com/.....st-rating/

but....  afraid that is one of our older template functions and has less flexibility than the newer ones...  and as such no real way with that template tag to get the data...

though, kind of a shame, as the data is readily available in the function and the db query already pulls the needed data...

So I would just go ahead and edit the template function and add it yourself...  towards the end you will see where the number of ratings is output...  just add another output statement there and calculate the rating using $sfpost->ratings_sum / $sfpost->vote_count...  be cautious of divide by zero there...

I will open a ticket for us to update the template function to current standards, including a getter option (just return data so you can do what you want)...

Avatar
Gomlers
Member
Free Members
sp_UserOfflineSmall Offline
Mar 16, 2013 - 3:02 pm

Thank you again for your help.

Do you mind writing the whole function for me, so I just can copy/paste it?

I am the worst programmer ever born... embarassed

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 17, 2013 - 4:43 am

Steve (Mr Papa) has actually gone on vacation for a couple of weeks. I don't mind taking a look at the function when I am able - I have never studied it - to see if I can work out what he was referring to.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Gomlers
Member
Free Members
sp_UserOfflineSmall Offline
Mar 29, 2013 - 10:05 pm

Sure! I would love to see this work :)

When you have the time...

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 31, 2013 - 8:07 am

It is not forgotten...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 5, 2013 - 2:00 pm

just pushed out an update to this plugin that gives you an option to include the average now...

Avatar
Gomlers
Member
Free Members
sp_UserOfflineSmall Offline
Apr 13, 2013 - 6:38 pm

Exactly what I was aiming for :)

Thanks!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 13, 2013 - 6:45 pm

good to hear.  thanks for the update.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625