Template Top Level 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 level players in your website's sidebar.

Preview:
sidebar top level.png

Code:
PHP:
$levelRankingData = LoadCacheData('rankings_level.cache');
$topLevelLimit = 5;
if(is_array($levelRankingData)) {
    $Character = new Character();
    $topLevel = array_slice($levelRankingData, 0, $topLevelLimit+1);
    echo '<div class="panel panel-sidebar">';
        echo '<div class="panel-heading">';
            echo '<h3 class="panel-title">Top Level<a href="'.__BASE_URL__.'rankings/level" 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">Level</th>';
                echo '</tr>';
                foreach($topLevel 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:
$topLevelLimit = 5;
The list of players is taken from the Top Level ranking cache, so make sure you have that working well.

That's it :)
 
Top