Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

ssi_topPoster Help

Aloittaja NIAB, heinäkuu 19, 2013, 07:42:15 IP

« edellinen - seuraava »

NIAB

Hey SMF'ers,

Trying to find a simple method of showing the top posters avatar with the ssi function. Any solutions? Thanks

EDIT

Here's the code I am currently trying to work with. Not sure where it is going wrong, but here it is :)
Koodi ("ssi_topPoster") [Valitse]

// Show the top poster's name and profile link.
function ssi_topPoster($topNumber = 1, $output_method = 'echo')
{
global $db_prefix, $scripturl, $smcFunc;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT id_member, real_name, posts
FROM {db_prefix}members
ORDER BY posts DESC
LIMIT ' . $topNumber,
array(
)
);
$return = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$return[] = 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'],
'avatar' => '<img src =' .$scripturl. '?action=dlattach;attach=' . $row['id_member'] . ';type=avatar />',
);
$smcFunc['db_free_result']($request);

// Just return all the top posters.
if ($output_method != 'echo')
return $return;

// Make a quick array to list the links in.
$temp_array = array();
foreach ($return as $member)
$temp_array[] = $member['link'];

echo implode(', ', $temp_array);
}


I have just added the following too it.
Koodi ("Addition") [Valitse]

'avatar' => '<img src =' .$scripturl. '?action=dlattach;attach=' . $row['id_member'] . ';type=avatar />',


And here's how I am using it on my custom index page
Koodi ("Index") [Valitse]

$return = ssi_topPoster(1,'array');
foreach ($return as $topposter)
{
echo'<img src ="http://www.*****com/forum/index.php?action=dlattach;attach=',$topposter['id'],';type=avatar"/>';
echo'', $topposter['avatar'] ,'';
echo'', $topposter['link'] ,'';
echo'', $topposter['posts'] ,'';
}


I would have though $topposter['avatar'] should have worked. But to try test it I also added a similar img src to it. No luck.. any help would be grateful.

EDIT

Think I may have found the issue..

The member ID is "1" where the avatar is "3" ... ...

NIAB

Found a Portal module that does what I want.

Credits: Dream Portal - SoloGhost (Link)

Advertisement: