TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 08:26:30 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 74
  • Total: 74

Users Post Count block

Started by darkangel, January 17, 2021, 01:50:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darkangel

Many moons ago I had gotten some code to make a block which emoved the avatars, and added the code for the admins NOT to be included, we talk too much and can't win the prizes offered....LOL
Yes, I did try it, too old so it no workie right.  Can someone rig up the code so that I can insert it or remove what is not needed by our asylum??

Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

@rjen

If you provide the code that does not work we may be able to fix it , without that it is only guessing what you want to do
Running Latest TP on SMF2.1 at: www.fjr-club.nl

@rjen

The search function worked fine for me... I assume this was the code you referred to (?), and I just pasted this in a PHP block in my 2.0.17 forum and it works fine...

Quote from: IchBin on February 09, 2014, 04:10:48 AM
Well I just tried this code and it worked fine:


global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 45;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="10">';

foreach ($users as $user)
{
$admins = array(1,2);
if (in_array($user['id'], $admins))
continue;
echo '
<tr>

<td><h5 style="margin: 4px,0,0,4px;">'.$user['link'].'</h5></td><td><h5 style="margin: 4px,0,0,4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';


Note that the exclusion on admins is by poster ID (1 and 2) so you need to adapt this array if you have other users you wish to exclude now...

$admins = array(1,2)
Running Latest TP on SMF2.1 at: www.fjr-club.nl

darkangel

thank you so much y'all. I have been fighting this sight for ages and now I need to remember how to shrink the font size to fit into the block better.

This was the code I had and used but the silly thing would not work and gave errors. It works great just text is too big.
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

@rjen

I saw the code uses the H5 tag, you can change that...
This is for example with the regular font size and 20 top posters:


global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 20;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="10">';

foreach ($users as $user)
{
$admins = array(1,2);
if (in_array($user['id'], $admins))
continue;
echo '
<tr>

<td>'.$user['link'].'</td><td style="text-align:right;min-width:4em;">'. $user['posts'] .'</td>
</tr>';
}

echo '
</table>';
Running Latest TP on SMF2.1 at: www.fjr-club.nl

darkangel

Thanks ever so much, looks fantastic now and we admins are not in there, one of the prizes is nice too... :2funny:
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

@rjen

Running Latest TP on SMF2.1 at: www.fjr-club.nl

darkangel

Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes