Change Karma Display in KarmaLeaderBoard from Decimal to Integer

r0obertr0obert
edited October 2014 in Vanilla 2.0 - 2.8

vanilla v2.1.3, bootstrap and the latest versions of KarmaBank & KarmaLeaderboard

I have managed to change how karma is displayed in the KarmaBank by adding this line to locale.php:

$Definition['KarmaBank.NumberFormat'] = '%d';

It is working perfectly, but KarmaLeaderBoard still shows decimals, eg. 100.00 instead of 100.

Any ideas?

Comments

  • peregrineperegrine MVP
    edited October 2014

    Frankly @r0obert , I was going to have this plugin deleted since it is old and since I don't use Karma plugin and I never received any donations for the plugin. >:)

    but you could try in class.karmaleaderboardmodule.php

    change

     $KarmaName = Gdn_Format::Text($Name);
    

    to

     $KarmaName = Gdn_Format::Text($Name);
     $Balance = sprintf(T('KarmaBank.NumberFormat',"%01.2f"),$Balance) ;
    

    but I am no longer supporting it, just so you know.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks for your answer and I'm sorry to hear that but I can't find

    $KarmaName = Gdn_Format::Text($Name);

    in class.karmaleaderboardmodule.php

    This is what I have:

    <?php if (!defined('APPLICATION')) exit();
    
    class KarmaLeaderBoardModule extends Gdn_Module {
    
    
     public function AssetTarget() {
          return 'Panel';
       }
    
     public function ToString() {
    
    
        echo "<div id=\"KarmaLeaderBoard\" class=\"Box KarmaLeaderBoardBox\">";
    
        echo "<h4>";
        echo T('Karma Leaders');
        echo "</h4>";
    
    
           echo '<ul class="PanelInfo PanelKarmaBankBalance">';
                 $limit =   C('Plugins.KarmaLeaderBoard.Limit');
                 if ($limit < 1)   $limit = 5;
                 $KLBArray = KarmaLeaderBoardModel::GetKarmaBal($limit);
    
    
                 for($x=0;$x < $limit; $x++) {
    
                 $UID =    $KLBArray[$x]['UserID'];  
                 $Name =  $KLBArray[$x]['Name'];  
                 $Photo =  $KLBArray[$x]['Photo']; 
                 $Balance =  $KLBArray[$x]['Balance']; 
                 $Email = $KLBArray[$x]['Email'];
    
                  $Object->UserID = $UID;
                  $Object->Name = $Name;
                  $Object->Photo = $Photo; 
                  $Object->Email = $Email; 
                  $User = UserBuilder($Object);
                  $photo =   UserPhoto($User,array('LinkClass'=>'ProfilePhotoCategory','ImageClass'=>'ProfilePhotoKarma'));
               echo '<p class="klbspacer" ></p>';
               echo '<li class="klbanchor">';
    
                $Href =  "/profile/$Name/$UID";
                if ($photo) {
                echo UserPhoto($User,array('LinkClass'=>'ProfilePhotoCategory','ImageClass'=>'ProfilePhotoKarma'));
                 echo UserAnchor($User);
                } else  {
                echo UserAnchor($User);
                }
                 echo "<span class=\"Aside\"><span class=\"Count\">" . T('Points: ') . $Balance . "</span></span>";
                echo '</li>';
             }
         echo "</ul>";
          echo "</div>";
    
    
       }
    }
    

    Thanks again!

  • peregrineperegrine MVP
    edited October 2014

    Ah, I have totally different code in my altered version. :) that no longer looks like yours :)

    try putting

    $Balance = sprintf(T('KarmaBank.NumberFormat',"%01.2f"),$Balance) ;

    above line 50 in what you displayed

    logically I would try that.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • r0obertr0obert
    edited October 2014

    @peregrine You're amazing, it worked!

    Check your PayPal (#KarmaLeaderboard), it's not much though, thanks again!

    :)

  • @r0obert said:
    peregrine You're f*cking amazing, it worked!

    Check your PayPal (#KarmaLeaderboard), it's not much though, thanks again!

    :)

    thanks. got it. much appreciated.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.