Template Top Resets sidebar block

Mon

Administrator
Developer
#1
Hello,

In this thread you will find a little code snippet that will allow you to show the top x resets players in your website's sidebar.

Preview:
sidebar top resets.png

Code:
PHP:
$resetsRankingData = LoadCacheData('rankings_resets.cache');
$topResetsLimit = 5;
if(is_array($resetsRankingData)) {
    $Character = new Character();
    $topResets = array_slice($resetsRankingData, 0, $topResetsLimit+1);
    echo '<div class="panel panel-sidebar">';
        echo '<div class="panel-heading">';
            echo '<h3 class="panel-title">Top Resets<a href="'.__BASE_URL__.'rankings/resets" class="btn btn-primary btn-xs pull-right" style="text-align:center;width:22px;">+</a></h3>';
        echo '</div>';
        echo '<div class="panel-body">';
            echo '<table class="table">';
                echo '<tr>';
                    echo '<th></th>';
                    echo '<th>Player</th>';
                    echo '<th class="text-center">Resets</th>';
                echo '</tr>';
                foreach($topResets as $key => $row) {
                    if($key == 0) continue;
                    $characterIMG = $Character->GenerateCharacterClassAvatar($row[1],false,false);
                    echo '<tr>';
                        echo '<td><img src="'.$characterIMG.'" width="20px" height="auto" /></td>';
                        echo '<td>'.$row[0].'</td>';
                        echo '<td class="text-center">'.$row[2].'</td>';
                    echo '</tr>';
                }
            echo '</table>';
        echo '</div>';
    echo '</div>';
}
You must add this to your template's sidebar, here:
https://github.com/lautaroangelico/WebEngine/blob/master/templates/redzone/inc/modules/sidebar.php

By default, it will take the Top 5, but you can change the amount of results to show by editing the variable:
PHP:
$topResetsLimit = 5;
The list of players is taken from the Top Resets ranking cache, so make sure you have that working well.

That's it :)
 
Top