MyBB Community Forums

Full Version: Post Reputation in post.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello again,
I wanted to add easier reputation for the posts and placed the button under the posts message with the reputation of that post counter. Code:
[php]
<div><span style="background-color:<?php if($post['reputation'] >0) { echo '#2BCF2B;'; } else  if($post['reputation'] ==0) { echo '#d5dde5;'; } else if($post['reputation'] <0) { echo '#DE2626;'; }?>font-size:0.8em;padding:5px;5px;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;color:#000;text-decoration:none;z-index:5000; float:right;">{$post['reputation']}</span><span style="float:right; line-height:2;">{$post['button_rep']}</span>
</div>

Don't worry about the PHP Code inside the postbit template, because it's working good, I've installed the PHP rendering in templates on my forum.
The problem is, although I'm using the $post['reputation'] variable on that, it isnt the POST reputation, it has the value of total reputation of the user who wrote this posts. That means, when the user for example has only 1 reputation point, we can see all his posts marked have 1 reputation point.

Is there any way I can fix it?
Thanks in advance.
There is no variable that contains the reputation count of a specific post in MyBB core. You have to query the mybb_reputation table and COUNT all rows with pid equal to $post['pid'].
Could you explain me what is the pid in $post['pid'] accutally? It's the post id, right?
Yes.
Is it wise to query it in functions_post.php, in the build_postbit function? I don't see much other choice...

Alright, i have this code
$query69 = $db->write_query("SELECT SUM(reputation) AS reputacja_suma FROM mybb_reputation WHERE `pid` = '".$post['pid']."");
$postrep = $db->fetch_array($query69);

$post['post_reputation'] = $postrep['reputacja_suma'];
eval("\$post['post_reputation'] = \"".$postrep['reputacja_suma']."\";");

And it doesnt work... Anyone?

Alright, I figured it out, i was missing one quote in the query. Works fine now, thanks a lot.