2013-03-24, 11:03 AM
We can see in thread view - all the posts have a button to give reputation to the user for the post. However; if you click the reputation button in your own post - it comes out as an error message stating:
I felt this is somehow unwanted. So, here I'm to show you how we can hide reputation button from own posts.
We are going to hide the button using jQuery. So, at first include jQuery library to your board using the well-known method, if it is not already.
Next, open the template:
ACP > Templates & Styles > Templates > {$theme_name} Templates > Postbit Templates > postbit_rep_button
Find the code of the Button image (works fine with css buttons too) and bind it in an ID.
<span id="selfrep{$post['pid']}"><a href=" .... ....</a></span>
For example:
The default theme's code:
Change it to:
Now the decision making and hiding part using jQuery. Add at the very end of the same template:
Save the template and you are done!!!
Snap:
Happy coding.
Quote:You cannot add to your own reputation.
I felt this is somehow unwanted. So, here I'm to show you how we can hide reputation button from own posts.
We are going to hide the button using jQuery. So, at first include jQuery library to your board using the well-known method, if it is not already.
Next, open the template:
ACP > Templates & Styles > Templates > {$theme_name} Templates > Postbit Templates > postbit_rep_button
Find the code of the Button image (works fine with css buttons too) and bind it in an ID.
<span id="selfrep{$post['pid']}"><a href=" .... ....</a></span>
For example:
The default theme's code:
<a href="javascript:MyBB.reputation({$post['uid']},{$post['pid']});"><img src="{$theme['imglangdir']}/postbit_reputation.gif" alt="{$lang->postbit_reputation_add}" title="{$lang->postbit_reputation_add}" /></a>
Change it to:
<span id="selfrep{$post['pid']}"><a href="javascript:MyBB.reputation({$post['uid']},{$post['pid']});"><img src="{$theme['imglangdir']}/postbit_reputation.gif" alt="{$lang->postbit_reputation_add}" title="{$lang->postbit_reputation_add}" /></a></span>
Now the decision making and hiding part using jQuery. Add at the very end of the same template:
<script type="text/javascript">
jQuery.noConflict();
jQuery(function() {
if({$post['uid']} == {$mybb->user['uid']}) {
jQuery('#selfrep{$post['pid']}').hide();
}
});
</script>
Save the template and you are done!!!
Snap:
Happy coding.