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

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

forummaker

Not sure how to do this. Any help would be great! Thanks.
I'm using "Custom Profile Field" mod and I would like to add some information from that mod in the block that I'm already currently using. I just can't figure out the code that pulls the information from the CPF that I'm trying to show. I've also posted this question to that mod at SMF, with no responses. Maybe I'm not asking the question properly.
SMF 1.1.8
Here is the code I have now:
It's a PHP block:
global $memberContext;
echo '<div align="center"></div>';
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberData(array($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>';

global $memberContext;
echo '<div align="center"></div>';
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberData(array($context['common_stats']['latest_member']['id']));
loadMemberContext($user_id);
if (!empty($memberContext[$user_id]['location']))
echo '<div align="center">'.$memberContext[$user_id]['location'].'</div>';


Here are a couple images, to give you an idea.



JPDeni

The information from the Custom Profile Fields is stored in the {$db_prefix}themes table, which has the structure

ID_MEMBER, ID_THEME, variable, value

In the case of CPF, the ID_THEME is always 1, so you don't have to worry about that. The variable is the name you gave to the field and the value is what the member entered.

It looks like you're only getting information about one person at a time, so search for the ID_MEMBER and the variable and you'll get the value. Do you need help with the query?

forummaker

Thanks for a response.
I just don't know enough about coding to even begin to understand what you're talking about. Sorry. I'm a quick learn though. I'll try what you suggested and see what I come up with. Thanks.

JPDeni

IOW, yes, you need help with the query. :)

Looking at your code, I see that you have some unnecessary duplication. Here's what I would try:


global $memberContext, $db_prefix;
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberData(array($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>';
if (!empty($memberContext[$user_id]['location']))
  echo '<div align="center">'.$memberContext[$user_id]['location'].'</div>';
$result = db_query("SELECT value
                    FROM {$db_prefix}themes
                    WHERE ID_MEMBER = $user_id
                    AND variable = XXXXXXX
                    LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result));
mysql_free_result($result);
if ($row['value'] > '')
  echo '<div align="center">'.$row['value'].'</div>';


Notice the bit that says variable = XXXXXXX. In place of the XXXXXXX, put the name of the CPF that you defined when you created the field.

forummaker

Thanks.  ;)
Here's what I have:
global $memberContext, $db_prefix;
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberData(array($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>';
if (!empty($memberContext[$user_id]['location']))
  echo '<div align="center">'.$memberContext[$user_id]['location'].'</div>';
$result = db_query("SELECT value
                    FROM {$db_prefix}themes
                    WHERE ID_MEMBER = $user_id
                    AND variable = Member of
                    LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result));
mysql_free_result($result);
if ($row['value'] > '')
  echo '<div align="center">'.$row['value'].'</div>';


Tried working with it, but keep getting this error message in the block:

Parse error: syntax error, unexpected ')' in /home/content/j/u/m/html/website/forums/Sources/Load.php(1753) : eval()'d code(52) : eval()'d code on line 16

Hmm.....

IchBin

$row = mysql_fetch_assoc($result));

Should be:
$row = mysql_fetch_assoc($result);

forummaker

Tried that, now getting this....

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'of
LIMIT 1' at line 4
File: /home/content/j/u/m/html/website/forums/Sources/Load.php(1753) : eval()'d code(52) : eval()'d code
Line: 15

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.8, while your database is at version 1.1.6. The above error might possibly go away if you execute the latest version of upgrade.php.

JPDeni

Okay. Sorry. I shouldn't post things when I'm sick.


AND variable = Member of


should be


AND variable LIKE 'Member of'

GKDantas

Any way to create columns too? In truth I would like away to put a fixed image size and choose how many columns and lines in a table, but without using scroling... can someone help?

G6Cad


This website is proudly hosted on Crocweb Cloud Website Hosting.