collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 861
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Customize Top Poster Block  (Read 8306 times)

0 Members and 1 Guest are viewing this topic.

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Customize Top Poster Block
« on: January 15, 2012, 11:16:40 PM »
How can I customize top poster block like below image.



- User Avatar
- Total Post

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Customize Top Poster Block
« Reply #1 on: January 29, 2012, 10:01:14 PM »
That's pretty easy to do. When it's done I'll post back.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #2 on: February 10, 2012, 12:15:16 PM »
thanks Blue. Waiting for your help.

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #3 on: March 09, 2012, 06:48:38 AM »
Still waiting.....  :(

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: Customize Top Poster Block
« Reply #4 on: March 09, 2012, 07:21:29 PM »
Still waiting.....  :(

Please be patient. The boy does get very busy at times.
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Customize Top Poster Block
« Reply #5 on: March 10, 2012, 09:45:05 AM »
As Brack said, I have some REALLY busy days :) I'm going to work on it this weekend :D
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #6 on: March 17, 2012, 02:24:43 PM »
Another week passed  ;D

Anyway waiting!


Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #7 on: April 01, 2012, 12:29:38 PM »
As Blue is too busy.

So any one else who could help regarding top poster block?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Customize Top Poster Block
« Reply #8 on: April 01, 2012, 06:50:08 PM »
I can just write a custom php block for this.

You want:

- User Avatar
- User Name
- Total Posts

or just the user name to appear when hovering over the avatar (and link to user profile when clicking on it)?
What is the avatar size you want displayed?

Also since you want the avatars to appear 4 in one row I assume this for a top/bottom block?
Do you want some javascript pages? .. so that you can have it display ie. 20 users but only 8 at a time where the user clicks the next button to go to the next 8 users etc?

« Last Edit: April 01, 2012, 06:59:25 PM by Underdog »

Offline mrpjh

  • Newbie
  • Posts: 4
  • SMF Version: 2.0.2
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #9 on: April 01, 2012, 07:01:11 PM »
have a look at

sources/PortalBlocks.php
first try near line 555
Code: [Select]
if (!empty($color_profile[$p['id']]['link']))
add ['avatar'] after ['link']
have a deep dive in function sp_top_poster

sorry i am very new to SMF actually this one is my first visit not sure in future i will get chance to revisit or not however i hope my ref give you a start instead of waiting for reply

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Customize Top Poster Block
« Reply #10 on: April 01, 2012, 10:05:15 PM »
pixeleyes,

Here is a custom php block that you can use: Click Here

To have it display such as you suggested, change some integers and a boolean to the values shown below:
Code: [Select]
$number_users = 8;
$show_name = false;
$per_row = 4;
$rows = 2;
... and it will only display 8 users, no names underneath the avatar and with no pages.

Like this:
Code: [Select]
/* Display Frequent Posters for SMF 2.0x by Underdog @http://askusaquestion.net */
/* Format: Horizontal javascript pages */
/* v1.0 */

global $smcFunc, $scripturl, $boardurl;

/* Adjust these */
$number_users = 8;
$lang = ' Posts';
$show_posts = 'Show posts from this user';
$show_profile = 'Show the user profile of ';
$none = 'No users selected';
$show_name = false;
$avatar_width = 50;
$avatar_height = 50;
$row_height = 100; /* <-- adjust depending on amount of text shown under avatar */
$user_name_max = 35; /* <-- max chars for user name display */
$per_row = 4;
$rows = 2;
$prev = 'Prev';
$next = 'Next';

/* Do not edit below this line */

$query = '(users.posts > 0 AND is_activated = 1)';
$datum = array( 'id_member', 'posts', 'real_name', 'avatar', 'filename', 'id_attach');
$x = 0;
$count = 0;
$users = array();
$limit = !empty($number_users) ? (int)$number_users : 20;
$cell_width = 100 / (int)$per_row;

$pages = '<script type="text/javascript"><!--
        var pager = new frequentPager("new", '.(int)$rows.');
        pager.init();
        pager.showPageNav("pager", "l8stPagePosition");
        pager.showPage(1);
    //--></script>';

/* Some js to control the pages */
echo '<script type="text/javascript">
function frequentPager(tableName, itemsPerPage) {
    this.tableName = tableName;
    this.itemsPerPage = itemsPerPage;
    this.currentPage = 1;
    this.pages = 0;
    this.initiated = false;
   
    this.showRecords = function(from, to) {       
        var rows = document.getElementById(tableName).rows;
        // i starts from 1 to skip table header row';
echo "
        for (var i = 1; i < rows.length; i++) {
            if (i < from || i > to) 
                rows[i].style.display = 'none';
            else
                rows[i].style.display = '';
        }";
echo '
    }
   
    this.showPage = function(pageNumberFrequent) {
    if (! this.initiated) {
    alert("not initiated");
    return;
    }';
echo "
        var oldPageAnchor = document.getElementById('pg'+this.currentPage);
        oldPageAnchor.className = 'pg-normal';
       
        this.currentPage = pageNumberFrequent;
        var newPageAnchor = document.getElementById('pg'+this.currentPage);
        newPageAnchor.className = 'pg-selected';
       
        var from = (pageNumberFrequent - 1) * itemsPerPage + 1;
        var to = from + itemsPerPage - 1;
        this.showRecords(from, to);
    }   
   
    this.prev = function() {
        if (this.currentPage > 1)
            this.showPage(this.currentPage - 1);
    }
   
    this.next = function() {
        if (this.currentPage < this.pages) {
            this.showPage(this.currentPage + 1);
        }
    }                       
   
    this.init = function() {
        var rows = document.getElementById(tableName).rows;
        var records = (rows.length - 1);
        this.pages = Math.ceil(records / itemsPerPage);
        this.initiated = true;
    }";
echo '
    this.showPageNav = function(pagerName, positionId) {
    if (! this.initiated) {
    alert("not initiated");
    return;
    }
    var element = document.getElementById(positionId);';
echo "
    var pagerHtml = '<span onclick=";
echo '"';
echo "' + pagerName + '.prev();";
echo '" class="pg-normal"> « ', $prev, ' </span> | ';
echo "';
        for (var page = 1; page <= this.pages; page++)
            pagerHtml += '<span id=";
echo '"';
echo "pg' + page + '";
echo '" class="pg-normal" onclick="';
echo "' + pagerName + '.showPage(' + page + ');";
echo '">';
echo "' + page + '</span> | ';
        pagerHtml += '<span onclick=";
echo '"';
echo "'+pagerName+'.next();";
echo '" class="pg-normal"> ', $next,' »</span>';
echo "';           
       
        element.innerHTML = pagerHtml;
    }
}
function regenerateFrequent()
{
window.location.reload()
}

function regenerateFrequentPosters()
{
if (document.layers)
{
appearFrequent()
setTimeout(";
echo '"window.onresize=regenerateFrequent",450)
}
}

function changeFrequentText(whichcontent)
{
if (document.all||document.getElementById)
{
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML=';
echo "'<div style=";
echo '"font-family:Arial Narrow Bold;font-size:small;">';
echo "'+whichcontent+'</div>'
}
else if (document.layers)
{
document.d1.document.d2.document.write('<div style=";
echo '"font-family:Arial Narrow Bold;font-size:small;">';
echo "'+whichcontent+'</div>')
document.d1.document.d2.document.close()
}

}

function appearFrequent()
{
document.d1.visibility='show'
}
</script>";
/* end of js controller */

$result = $smcFunc['db_query']('', "SELECT users.id_member, users.posts, users.real_name, users.avatar, users.is_activated, att.id_attach, att.filename FROM {db_prefix}members AS users
LEFT JOIN {db_prefix}attachments AS att ON (att.id_member = users.id_member)
WHERE {$query} ORDER BY users.posts DESC LIMIT {$limit}");
while ($val = $smcFunc['db_fetch_assoc']($result))
{                     
foreach ($datum as $data)
{
if (empty($val[$data]))
$val[$data] = false;

$users[$count][$data] = $val[$data];                                               
}
$count++;
}
$smcFunc['db_free_result']($result);
echo '
<script type="text/javascript">
<!--
window.onload=regenerateFrequentPosters
//-->
</script>';
if ($count == 0)
echo '
<div style="text-align:center">', $none, '</div>';
else
{
echo '
<table id ="new" style="width:100%;">
<tr>
<td>&nbsp;</td>
</tr>';
foreach ($users as $user)
{
if ((empty($user['posts'])) || !$user['posts'])
continue;
if ($x == 0)
echo '
<tr>';

$x++;
 
if (!$user['avatar'] && !$user['filename'])
$user['avatar'] = $boardurl . '/avatars/noavatar.gif';
elseif (!$user['avatar'])
$user['avatar'] = $scripturl . '?action=dlattach;attach='.$user['id_attach'].';type=avatar';
elseif (substr($user['avatar'], 0, 4) != 'http')
$user['avatar'] = $boardurl .'/avatars/' . $user['avatar'];

$name = strlen($user['real_name']) >= (int)$user_name_max ? $name = substr($user['real_name'],0,(int)$user_name_max).'...':$user['real_name'];
echo '
<td style="text-align:center;width:'.(int)$cell_width.'%;">
<div style="height:'.$row_height.'px;overflow:hidden;">
<a href="'.$scripturl.'?action=profile;u='.$user['id_member'].'" title="'.$show_profile,$user['real_name'].'">
<img src="'. $user['avatar'] . '" style="max-height:'.$avatar_height.'px;max-width:'.$avatar_width.'px;" alt="" />
</a>
<br />';
if ($show_name)
echo '
<a href="'.$scripturl.'?action=profile;u='.$user['id_member'].'" title="'.$user['real_name'].'">',$name,'</a>
<br />';

echo '
<a href="'.$scripturl.'?action=profile;area=showposts;u='.$user['id_member'].'" title="'.$show_posts.'">', $user['posts'], $lang, '</a>
</div>
</td>';
if ($x > ((int)$per_row -1))
{
$x=0;
echo '
</tr>';
}
}

echo '
</table>';

if (((int)$per_row * (int)$rows) != (int)$number_users)
echo '
<br />
<div id="l8stPagePosition" style="text-align:center;">&nbsp;</div>
<div style="text-align:center;">', $pages, '</div>';
}


With this block you have the option of customizing it at the top of the block code.
« Last Edit: April 01, 2012, 11:34:14 PM by Underdog »

Offline pixeleyes

  • Jr. Member
  • **
  • Posts: 72
  • SMF Version: None
  • SP Version: 2.3.3
Re: Customize Top Poster Block
« Reply #11 on: April 05, 2012, 09:37:34 AM »
Thank you so much UNDERDOG  :nervous-happy: