Skip to main content
Top Users Started by ksamochkin · · Read 2291 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

Top Users

How to implement the Top Users feature? On SMF, I was able to implement this:
Code: [Select]
 function ssi_topautor()
{
global $smcFunc, $scripturl, $modSettings, $settings, $txt;

// Height and width of avatar
$width = '40px';
$height = '100%';
// Number of top posters displayed
$topPoster = 8;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, mem.avatar, 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 show_online = 1 AND mem.is_activated = 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'],
'avatar' => array(
    'image' => empty($row['avatar']) ? ($row['id_attach'] > 0 ? 'src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : '') : (stristr($row['avatar'], 'http://') ? 'src="' . $row['avatar'] . '" alt="" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : 'src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />'),
    ),
);
}

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

// Output our array of users with avatar, posts, and name
echo '
<div>';

foreach ($users as $user)
{
echo '
<div style="width:25%;float:left;">',empty($user['avatar']['image']) ? '<a href="'.$user['href'].'"><img src="/default.png" width="'.$width.'" height="'.$height.'" alt="" title="'.$user['name'].'" /></a>' : '<a href="'.$user['href'].'"><img '.$user['avatar']['image'].'</a>';
echo '
</div>
<div style="width:75%;float:left;"><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .' '.$txt['posts'].'</h5></div><p style="clear:both;"></p>';
}

echo '
</div>';

}
it looks like this:
Clipboard01.jpg
you can view it http://zdforum.ru/portal.php
but on ElkArte it does not work

Re: Top Users

Reply #1

You need to use the Elkarte db instance not smcFunc