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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 333
  • Total: 333

[Block] Newest member block with Avatar image which links to their profile

Started by gbingo, August 23, 2006, 06:04:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

There's a lot of variation in the code here. Post yours so I know what I'm starting with.


JPDeni

I need the code you're using already. I know what you want. I need to know what you have.

GKDantas

Sorry, here is the code

global $db_prefix, $memberContext;

$count = 3;
$users = array();

$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);

$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '<hr>';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</div>';
}


The $count allow to select how many users you want, but theres only BR tags to separate them all...

Thanks again

JPDeni

This should give you what you want:


global $db_prefix, $memberContext;

$count = 6;

$per_row = 3;
$users = array();

$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);

$display = 0;
echo '<table>';
foreach($users as $user_id) {
++$display;
if ($display == 1)
echo '<tr>';
loadMemberContext($user_id);
echo '<td>';
if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</div>';
echo '</td>';
if ($display == $per_row) {
echo '</tr>';
$display = 0;
}
}
echo '
<table>';

GKDantas

Looking great now... can I ask you one more thing? This way the avatar have any size and the layout get broken. Theres any way to add a size tag to the avatar image??

JPDeni

Not without completely rewriting the code, which I'd rather not do. However, there's a setting in SMF which will allow you to set a maximum size for avatars, which ought to make a difference. Go to Admin > Forum > Attachments and Avatars > Avatar Settings and set the maximums there.


This website is proudly hosted on Crocweb Cloud Website Hosting.