TinyPortal

Development => Support => Topic started by: darkangel on February 18, 2012, 10:40:00 AM

Title: in 2.0 smf
Post by: darkangel on February 18, 2012, 10:40:00 AM
how do I show the top posters in the block as a column and not with commas like in 1.1.16?

the old code does not play well anymore...lol

in block:
ssi_topPoster(25);




Title: Re: in 2.0 smf
Post by: Skhilled on February 18, 2012, 10:58:43 AM
There is a "Top Posters" block built into SMF 2.0. Create a new block (or change the old block if it will let you) with SSI functions as the option and save it. Then edit the block and choose "Top Posters".
Title: Re: in 2.0 smf
Post by: darkangel on February 18, 2012, 11:13:12 AM
thanks but, how to make them appear as a column with totals and not with commas
Title: Re: in 2.0 smf
Post by: Skhilled on February 18, 2012, 08:08:21 PM
Sounds like you probably want a custom block.
Title: Re: in 2.0 smf
Post by: darkangel on February 18, 2012, 10:29:35 PM
if you please. I have the code used when they helped with the previous 1.1.16 version but it is not worded like what is in the SSI file, will that help?
Title: Re: in 2.0 smf
Post by: Skhilled on February 19, 2012, 09:08:26 AM
I'm not a coder but think you should post this in the block request board.
Title: Re: in 2.0 smf
Post by: darkangel on February 19, 2012, 10:03:44 AM
ok thanks
Title: Re: in 2.0 smf
Post by: ZarPrime on February 20, 2012, 12:43:08 PM
darkangel,

Post the code that worked with 1.1.16 so that I can look at it.  What is that other column in your picture you posted.  Is that each member's number of posts?

ZarPrime
Title: Re: in 2.0 smf
Post by: darkangel on February 20, 2012, 09:08:25 PM
the one in 1.1.6 show them in a column...left is name with the right showing actual posts

but

while trolling the area where requests are placed I foudn this code

in a php block:

global $smcFunc, $scripturl, $modSettings;

// Height and width of avatar
$width = '40px';
$height = '40px';
// 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
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="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : '') : (stristr($row['avatar'], 'http://') ? 'src="' . $row['avatar'] . '" alt="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : 'src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />'),
    ),
);
}

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

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

foreach ($users as $user)
{
echo '
<tr>
<td>',empty($user['avatar']['image']) ? '<a href="'.$user['href'].'"><img src="'.$settings['images_url'].'/noavatar.gif" width="'.$width.'" height="'.$height.'" alt="" title="'.$user['name'].'" /></a>' : '<a href="'.$user['href'].'"><img '.$user['avatar']['image'].'</a>';
echo '
</td>
<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';


That works nicely--sort of. it works with the avas being able to be adjusted in size and for showing up to 8 users but when I update the main forum and we have 20 showing this is gonna be reaalllllll long...lol

If we could try to remove the ava and just leave the name/post count that would be great.