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 :)
 

yhoon

New Member
#7
Pero como te dije el index del template es .html, no lee el php

HTML:
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>{{META_TITLE}}</title>
    <meta name="generator" content="WebEngine {{WEBENGINE_VERSION}}" />
    <meta name="author" content="Lautaro Angelico" />
    <meta name="description" content="{{META_DESCRIPTION}}" />
    <meta name="keywords" content="{{META_KEYWORDS}}" />
    <meta property="og:url" content="{{BASE_URL}}" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="{{META_TITLE}}" />
    <meta property="og:description" content="{{META_DESCRIPTION}}" />
    <meta property="og:image" content="{{TEMPLATE_FB_IMG}}" />
    <link rel="shortcut icon" href="{{PATH_TEMPLATE}}favicon.ico" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css?family=Roboto:400,700,300" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Cinzel" rel="stylesheet">
    <link href="{{PATH_TEMPLATE_CSS}}style.css" rel="stylesheet" media="screen">
    <link href="{{PATH_TEMPLATE_CSS}}profiles.css" rel="stylesheet" media="screen">
    <link href="{{PATH_TEMPLATE_CSS}}override.css" rel="stylesheet" media="screen">
    <script>
        var baseUrl = '{{BASE_URL}}';

    </script>
</head>

<body>
    <div id="fb-root"></div>
    <script>
        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s);
            js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=1439010682981422&version=v2.0";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));

    </script>
    {% if ADMCP_ACCESS %}
    <nav class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <a class="navbar-brand" href="{{PATH_ADMINCP_HOME}}"><img src="{{PATH_ADMINCP_HOME}}img/logo.jpg"></a>
        </div>
        <ul class="nav navbar-top-links navbar-right">
            <li><a href="{{PATH_ADMINCP_HOME}}" target="_blank"><i class="fa fa-fw fa-home"></i> AdminCP Home</a></li>
            <li><a href="{{BASE_URL}}logout/"><i class="fa fa-fw fa-power-off"></i> Log Out</a></li>
        </ul>
    </nav>
    {% endif %}
    <div id="header">
        <div id="headerLogo">
            <img src="{{PATH_TEMPLATE_IMG}}logo.png">
        </div>
        <div id="headerTime">
            <div id="serverTime_Wrap">
                <div class="serverTime_BoxOn" id="gstYourTime">
                    <span>{{lang('user_time')}}</span><time id="tLocalTime"></time>
                </div>
                <div class="serverTime_BoxOff">
                    <span>{{lang('server_time')}}</span><time id="tServerTime"></time>
                </div>
                <div class="serverTime_BoxOff">
                    <span>{{lang('languages')}}</span>
                    <time>
                        <a href="{{BASE_URL}}language/switch/to/sp">Spanish <img src="{{PATH_TEMPLATE_IMG}}sp.gif"></a>
                        <a href="{{BASE_URL}}language/switch/to/en">English <img src="{{PATH_TEMPLATE_IMG}}en.gif"></a>
                        </time>
                </div>
            </div>
        </div>
    </div>
    <div id="container">
        <div id="navbar">

            <!-- NAVBAR-->
            <ul>
                {% for LINK in NAVBAR_LINKS %}
                <li><a href="{{LINK.URL|raw}}">{{LINK.TITLE}}</a></li>
                {% endfor %}
            </ul>
        </div>
        <!-- CASTLE SIEGE BANNER -->
        {% if TEMPLATE_CS_BANNER %}
        <div id="castle-siege">
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <td class="cs-logo">{{TEMPLATE_OWNER_LOGO|raw}}</td>
                    <td class="cs-guild-info">
                        <span class="cs-guild-title">{{TEMPLATE_OWNER_NAME}}</span><br />
                        <span>{{lang('csbanner_txt_1')}}</span>
                    </td>
                    <td>
                        {{lang('csbanner_txt_2')}}<br />
                        <span class="cs-timeleft" id="cscountdown">
    {{TEMPLATE_CS_TIMELEFT.0}} <span>h</span> {{TEMPLATE_CS_TIMELEFT.1}} <span>m</span> {{TEMPLATE_CS_TIMELEFT.2}} <span>s</span>
                        </span>
                    </td>
                </tr>
            </table>
        </div>
        {% endif %}

        <div id="content">
            <div class="col-xs-8">
                <!-- MODULE HANDLER -->
                {% if MODULE_ON_ERROR %} {{MODULE_ON_ERROR|raw}} {% else %} {{ include(LOAD_MODULE) }} {% endif %}
            </div>
            <div class="col-xs-4">
                <!-- SIDEBAR-->
                {% if IS_LOGGED_IN %}
                <div class="panel panel-sidebar panel-usercp">
                    <div class="panel-heading">
                        <h3 class="panel-title">{{lang('usercp_menu_title')}}</h3>
                    </div>
                    <div class="panel-body">
                        <ul>
                            {% for LINK in USERCP_LINKS %}
                            <li><img src="{{LINK.ICON}}"><a href="{{LINK.URL|raw}}">{{LINK.TITLE}}</a></li>
                            {% endfor %}
                        </ul>
                    </div>
                </div>
                {% else %}
                <div class="panel panel-sidebar">
                    <div class="panel-heading">
                        <h3 class="panel-title">{{lang('module_titles_txt_2')}}</h3>
                    </div>
                    <div class="panel-body">
                        <form action="{{BASE_URL}}login" method="post">
                            <div class="form-group">
                                <label for="loginBox1">{{lang('login_txt_1')}}</label>
                                <input type="text" class="form-control" id="loginBox1" name="webengineLogin_user" required>
                            </div>
                            <div class="form-group">
                                <label for="loginBox2">{{lang('login_txt_2')}}</label>
                                <input type="password" class="form-control" id="loginBox2" name="webengineLogin_pwd" required>
                                <span id="helpBlock" class="help-block"><a href="{{BASE_URL}}forgotpassword">{{lang('login_txt_4')}}</a></span>
                            </div>
                            <button type="submit" name="webengineLogin_submit" value="submit" class="btn btn-primary">{{lang('login_txt_3')}}</button>
                        </form>
                    </div>
                </div>
                <div class="sidebar-banner"><a href="{{BASE_URL}}register"><img src="{{PATH_TEMPLATE_IMG}}register_sidebar_banner.jpg"/></a></div>
                {% endif %}

                {% if TEMPLATE_INFO_SHOW %}
                <div class="panel panel-sidebar">
                    <div class="panel-heading">
                        <h3 class="panel-title">{{lang('sidebar_srvinfo_txt_1')}}</h3>
                    </div>
                    <div class="panel-body">
                        <table class="table">
                            <tr>
                                <td>{{lang('sidebar_srvinfo_txt_2')}}</td>
                                <td> {{SERVER_INFO.ACCOUNTS}}</td>
                            </tr>
                            <tr>
                                <td>{{lang('sidebar_srvinfo_txt_3')}}</td>
                                <td> {{SERVER_INFO.ONLINES}}</td>
                            </tr>
                            <tr>
                                <td>{{lang('sidebar_srvinfo_txt_4')}}</td>
                                <td> {{SERVER_INFO.PLAYERS}}</td>
                            </tr>
                            <tr>
                                <td>{{lang('sidebar_srvinfo_txt_5')}}</td>
                                <td> {{SERVER_INFO.GUILDS}}</td>
                            </tr>
                        </table>
                    </div>
                </div>
                {% endif %}
                {% if TEMPLATE_EVENTS_MANAGER %}
                <div class="panel panel-sidebar">
                    <div class="panel-heading">
                        <h3 class="panel-title">Events Manager</h3>
                    </div>
                    <div class="panel-body">
                        <ul id="events">
                        </ul>
                    </div>
                </div>
                {% endif %}
                
                {% if TEMPLATE_YT_SHOW %}
                <div class="panel panel-sidebar">
                    <div class="panel-body">
                        <iframe width="271" height="152" src="{{TEMPLATE_YT_LINK}}" frameborder="0" allowfullscreen></iframe>
                    </div>
                </div>
                
                {% endif %}
                
                {% if TEMPLATE_FB_SHOW %}
                <div class="panel panel-sidebar">
                    <div class="panel-body">
                        <iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2F{{TEMPLATE_FB_LINK}}&tabs=timeline&width=271&height=300&small_header=true&adapt_container_width=true&hide_cover=false&show_facepile=false" width="271" height="300" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
                    </div>
                </div>
                
                {% endif %}

            </div>
        </div>
    </div>
    <div id="footer">
        <p>&copy; 2018 {{SERVER_NAME}}</p>
        <a href="http://Link donde lo vas a mandar">Frase</a>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="{{PATH_TEMPLATE_JS}}main.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>

</html>
 
Top