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

[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 2 Guests are viewing this topic.

rebelrose

Quote from: akulion on September 27, 2006, 11:29:26 PM
we need jpdeni or eldaka or thurnok or jocortina here :D

arent we shameless? lol

Not shameless, lol, just know when I am over my head.

akulion

they are so kind to us code challenged people :D

i wonder what we would do without them

rebelrose


rebelrose

Quote from: RebelRose on September 27, 2006, 06:47:36 PM
Will this also pull up avatars that are not in the avatar area, you know the ones uploaded by members?



global $db_prefix;
$query = "SELECT avatar FROM {$db_prefix}members WHERE ID_MEMBER = ".$context['common_stats']['latest_member']['id'];
$exec = db_query($query);
$row = mysql_fetch_assoc($exec);
echo "<div align='center'><img src='./avatars/".$row['avatar']."' alt='".$context['common_stats']['latest_member']['name']."'><BR>".$context['common_stats']['latest_member']['link']."</div>";
mysql_free_result($exec);




Anyone yet?

feline

To get the member avatar use this ...


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 ON (m.ID_MEMBER = a.ID_MEMBER)
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" />';
}


Fel

rebelrose

That didn't work right for me Fel, this is what I got from that:

feline

urg ... a small error in sql  ::)


$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__);


You can give me your complete code, then I make that correct

Fel

rebelrose

This is the code I am using:



global $db_prefix;
$query = "SELECT avatar FROM {$db_prefix}members WHERE ID_MEMBER = ".$context['common_stats']['latest_member']['id'];
$exec = db_query($query);
$row = mysql_fetch_assoc($exec);
echo "<div align='center'><img src='./avatars/".$row['avatar']."' alt='".$context['common_stats']['latest_member']['name']."'><BR>".$context['common_stats']['latest_member']['link']."</div>";
mysql_free_result($exec);




But it only brings up avatars that are in the avatar folders and not the ones they upload, I woudl like it to do both.

jacortina

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

rebelrose

Well I will look but I have no clue what I am looking for, clueless when it comes to code.

This website is proudly hosted on Crocweb Cloud Website Hosting.