MyBB Community Forums

Full Version: Reputation Bar with PHP in Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, I tried to create a php script to show instead of the number reputation, bars with php in templates, but don't work. This is the script:

<?php if ($post['userreputation'] < 0) {echo ("<img src=\"images/rep_bars/rep_neg.png\">");}

      elseif($post['userreputation'] == 0) {echo ("<img src=\"images/rep_bars/rep_neu.png\">");}

      elseif($post['userreputation'] > 0 && $post['userreputation'] <= "10") {echo ("<img src=\"images/rep_bars/rep_pos.png\">");}
?>
is it standalone php script or it is used in the postbit templates ?
Is used in the template postbit_classic
(2013-10-16, 05:35 PM)Meadp Wrote: [ -> ]Hi, I tried to create a php script to show instead of the number reputation, bars with php in templates, but don't work. This is the script:

<?php if ($post['userreputation'] < 0) {echo ("<img src=\"images/rep_bars/rep_neg.png\">");}

      elseif($post['userreputation'] == 0) {echo ("<img src=\"images/rep_bars/rep_neu.png\">");}

      elseif($post['userreputation'] > 0 && $post['userreputation'] <= "10") {echo ("<img src=\"images/rep_bars/rep_pos.png\">");}
?>

without a plugin mybb will ignore php in templates
I don't understand
(2013-10-16, 08:43 PM)Meadp Wrote: [ -> ]I don't understand

you can not add php to a template as mybb will ignore it
to add php code you have some options
  1. code a plugin
  2. install php in templates plugin
  3. install page manager plugin
  4. code a custom page

remember what you said
(2013-10-16, 05:44 PM)Meadp Wrote: [ -> ]Is used in the template postbit_classic
I used php in templates but don't work
(2013-10-17, 01:10 PM)Meadp Wrote: [ -> ]I used php in templates but don't work

try this
<?php 
if ($post['userreputation'] < 0) {echo '<img src="images/rep_bars/rep_neg.png">';}

      elseif($post['userreputation'] == 0) {echo '<img src="images/rep_bars/rep_neu.png">';}

      elseif($post['userreputation'] > 0 && $post['userreputation'] <= "10") {echo '<img src="images/rep_bars/rep_pos.png">';}
?>
Don't work, i don't know why..
same problem like me,
$post['userreputation'] is not a value, it is a link to web where you can add rep to somebody.
What you need is repuation value (variable). I still find out how to do it :v
Pages: 1 2