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: 329
  • Total: 329

[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.

feline

Use my code, you see the (local)avatar, upload avatar or external avatar.

Fel



rebelrose

Yes I got it now G6, it shows the avatar great, but not member name like in first code.

Fel Code:


global $context, $modSettings, $scripturl, $db_prefix;

$id = $context['common_stats']['latest_member']['id'];
$request = db_query("SELECT m.realName, m.avatar, a.ID_ATTACH
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}attachments AS a ON (m.ID_MEMBER = a.ID_MEMBER)
WHERE m.ID_MEMBER = $id", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
$row = mysql_fetch_assoc($request);

if(!empty($row['ID_ATTACH']))
$ava_url = $scripturl . '?action=dlattach;attach='. $row['ID_ATTACH'] .';type=avatar';
elseif(!empty($row['avatar']))
{
if(stristr($row['avatar'], 'http://') === FALSE)
$ava_url = $modSettings['avatar_url'] .'/'. $row['avatar'];
else
$ava_url = $row['avatar'];
}
mysql_free_result($request);
if(isset($ava_url))
echo '<img src="'. $ava_url .'" alt="" border="0" />';
}

jacortina

Quote from: feline on September 28, 2006, 09:11:45 PM
Use my code, you see the (local)avatar, upload avatar or external avatar.

Fel

As you do in the code I posted. It's SMF's own logic (calling their built-in function) for getting selected, user uploaded or remote avatars along with all the other information on a user.

rebelrose

Quote from: jacortina on September 28, 2006, 09:48:24 PM
As you do in the code I posted. It's SMF's own logic (calling their built-in function) for getting selected, user uploaded or remote avatars along with all the other information on a user.
Quote from: jacortina on September 28, 2006, 08:57:54 PM
Or you can let the SMF code get everything for you:
global $memberContext;
loadMemberContext($user_id);
echo $memberContext[$user_id]['avatar']['image'];


The loadMemberContext function comes back (the $memberContext array) with virtually EVERYTHING about a member (look in Sources/Load.php).


Is this the code you are talking about Jacortina?  I just use that code in a block and nothing else?

jacortina

I'm saying that the code is enough to get the avatar available into that array. Many other values for the user are also in that array.

But try this:
global $memberContext;
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberContext($user_id);
if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$context['common_stats']['latest_member']['link'].'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$context['common_stats']['latest_member']['link'].'</div>';


This should include the text '( No Avatar Yet )' if none is specified.

rebelrose

ok, I tried that and it shows the newest member and it says no avatar yet.

I am sorry, I just do not understand code well yet.

jacortina

Are you sure the latest member has specified an avatar in their profile?


This website is proudly hosted on Crocweb Cloud Website Hosting.