Support Forum

Stars rating / Post rating plugin – get the average post-vote number at the end

GO Gomlers
Gomlers
Member

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:

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?

8 Answers

New Answer

MP Mr Papa
Mr Papa
Member

I assume you have seen:  http://codex.simple-press.com/codex/plugins/our-plugins/available-plugins/post-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)…

GO Gomlers
Gomlers
Member

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

YS Yellow Swordfish
Yellow Swordfish
Member

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.

GO Gomlers
Gomlers
Member

Sure! I would love to see this work :)

When you have the time…

MP Mr Papa
Mr Papa
Member

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