Hi, very new here, thought I'd take a stab at a new block. I'd like to create a "newest member" block which shows the newest member to the forum, their avatar, and links to their profile. I'm going to attempt to start building this block by borrowing the newest member code from the bottom of the stock SMF template. Wish me luck :)
Good luck, looking forward to the code :up:
Good luck. I hope you are done soon so I can put it on my site. :)
Well getting the newest member was easy:
echo $context['common_stats']['latest_member']['link'];
Now to retrieve their avatar
You can take it off the roster page. I know you can use the code for the avatar.
Roster page? is that part of Tinyportal or SMF?
What file are you pulling the code from?? oh and the ssi feed for the member would be
<?php ssi_latestMember(); ?>
I was pulling it from SMF's theme template
All done! Here's my code: If someone can make it more efficient or flexible I'd appreciate it, but this works fine on my site:
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);
Let me test it out!
Hopefully it works!
:)
Edit: Hmmm...the avatar isn't showing.
i dont get any avatar image www.theteenzone.net/forum block on the right side
The only part that doesn't work is the avatar. Mine has a red x even after I added one to the new member's profile. :)
I think it has top do something with
echo "<div align='center'><img src='/avatars/".$row['avatar']."'
You need to take it from the avatar directory.
The avatar field is right. I'm thinking that you may need to have a complete URL in your img src tag.
I fixed it.
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);
Should work now.
See working example at Http://inflamehq.com/forum/
Look at the the bottom right.
It likely has to do with the part which reads <img src='/avatars/" - thats a hardcoded image directory. I don't know the Variable for the Forum URL (which should be there instead)
You did it right just left out the "." before /avatars.
Quote from: Jpg on August 23, 2006, 11:42:01 PM
I fixed it.
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);
Should work now.
See working example at Http://inflamehq.com/forum/
Look at the the bottom right.
Cool, that worked! :up: I like it, just too bad that the member has to select an avatar when they sign up. Otherwise you get the red x.
I think you can enable so the member HAS to choose an avatar when they sign up.
http://www.smfhacks.com/hacks/Avatar-Select-on-Register.html
Quote from: Jpg on August 24, 2006, 12:14:00 AM
I think you can enable so the member HAS to choose an avatar when they sign up.
http://www.smfhacks.com/hacks/Avatar-Select-on-Register.html
Ahh, I didn't know that :up:
You can thank me for the link later. :)
Thanks gbingo for the cool snippet!
Edit: Gbingo..you too can thank me later.
Thanks for the code its very nice
hey how about a block which shows the last 5 members and their avatars as well?
Only the avatars could be resized to a smaller size so we get a block like "recent topics" only this one would have recent members
And along side could be top 5 members with avatars
just a thought...anone wana take a crack at it?
It's supported by the 'latest_member' code.
Is it possible for this???
Maybe you can if you enable the code to remember the users "user #" and subtract one off the total. And then set up the code like that. Me being not that smart with php, won't know how to accomplish something like this. :\
well the idea in my head is this:
I made an image to best illustrate it...
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg175.imageshack.us%2Fimg175%2F3586%2Fmembersblockkb2.gif&hash=d48e8f090dc2e4fd693f7de8a5f5773b1457aacb)
It is totally possible - its just a matter of who wants to take a crack at iit:P
I understand. So basically something with member stats.
Now that we have the avatar code it shouldn't be that hard. But making the boxes and doing that could be.
Is there a top poster code?
Edit:Wow I have 1234 posts! :\
lol yea everyone has 1234 posts
the making the boxes isnt very hard at all its just a matter of declaring the table within echo statements to get the correct layout
The table layout code will be exactly like below, but where ti says in CAPS the code for the relevant stuff needs to be added.
echo '<table border="1" width="100%" id="table1" style="border-collapse: collapse">
<tr>
<td colspan="5">Member Stats</td>
</tr>
<tr>
<td rowspan="4">';
CODE FOR FORUM STATS HERE;
echo '</td>
<td colspan="2">Newest Members</td>
<td colspan="2">Top Posters</td>
</tr>';
PHP CODE TO MAKE IT LOOP FOR EACH FOR TOP 3
echo' <tr>
<td>CODE FOR AVATAR NEW MEMBER</td>
<td>CODE FOR NAME NEW MEMBER</td>
<td>CODE FOR AVATAR TOP POSTER</td>
<td>CODE FOR POSTS & TOPICS INFO TOP POSTER</td>
</tr>';
That should do the trick really but now the part is getting the PHP codes for those specific queries
What is the variable for Top Poster?
Is it ['top_poster']?
I highly doubt that...
hey do u know which file the Stats are called in?
Cos having a look at that will give us 90% of the info
The only thing that will remain is the Newest Members, for that I suspect we will require some PHP coding for doing that specifically - the minus 1 thing like u said
I was one step ahead of you.
I was looking at it 30 minutes before you posted.
// Poster top 10.
$members_result = db_query("
SELECT ID_MEMBER, realName, posts
FROM {$db_prefix}members
WHERE posts > 0
ORDER BY posts DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_posters'] = array();
$max_num_posts = 1;
while ($row_members = mysql_fetch_assoc($members_result))
{
$context['top_posters'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);
if ($max_num_posts < $row_members['posts'])
$max_num_posts = $row_members['posts'];
}
mysql_free_result($members_result);
foreach ($context['top_posters'] as $i => $poster)
$context['top_posters'][$i]['post_percent'] = round(($poster['num_posts'] * 100) / $max_num_posts);
LOL
I was just posting that
***edit***
ok ill post another bit: Top 10 Topic Starters
// Topic poster top 10.
$members_result = db_query("
SELECT ID_MEMBER, realName
FROM {$db_prefix}members
WHERE ID_MEMBER IN (" . implode(', ', array_keys($members)) . ")
GROUP BY ID_MEMBER
ORDER BY FIND_IN_SET(ID_MEMBER, '" . implode(',', array_keys($members)) . "')
LIMIT 10", __FILE__, __LINE__);
$context['top_starters'] = array();
$max_num_topics = 1;
while ($row_members = mysql_fetch_assoc($members_result))
{
$context['top_starters'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_topics' => $members[$row_members['ID_MEMBER']],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);
if ($max_num_topics < $members[$row_members['ID_MEMBER']])
$max_num_topics = $members[$row_members['ID_MEMBER']];
}
mysql_free_result($members_result);
foreach ($context['top_starters'] as $i => $topic)
$context['top_starters'][$i]['post_percent'] = round(($topic['num_topics'] * 100) / $max_num_topics);
But we need global arrays.
Edit: Something like...
global $txt, $scripturl, $db_prefix, $modSettings, $user_info, $context;
I like where this is going 8)
Lol...Yeah. Maybe I should test out some of the codes in a block and see what happens.
yea its complicated - but hopefully we can get part of it to work lol
<< scratches his head trying to understand the code
Brb, I'm downloading php editors on my computer for help.
dang i tested things and it dosent look too good
we need professional help!!
Don't worry dude. Everything is gonna be A-ok.
I tested it too and it was just a header with nothing in the box.
added to block snippet index
Is it possible to have the script check for an avatar and if they don't have one, just not display the avatar?
Well actually it'll just show text in firefox. it'll repeat their name again. That's why you use the mod I suggested on the other page. ;)
hey any progress with that last 3 thingie? lol
Well I haven't been focusing on this lately. We need better coders like JPdeni, Storm,etc...
:2funny: we are hopeless
Apparently so. Maybe I'll take another whack at it. :)
Edit: The codes we have now...
The Table
echo '<table border="1" width="100%" id="table1" style="border-collapse: collapse">
<tr>
<td colspan="5">Member Stats</td>
</tr>
<tr>
<td rowspan="4">';
CODE FOR FORUM STATS HERE;
echo '</td>
<td colspan="2">Newest Members</td>
<td colspan="2">Top Posters</td>
</tr>';
PHP CODE TO MAKE IT LOOP FOR EACH FOR TOP 3
echo' <tr>
<td>CODE FOR AVATAR NEW MEMBER</td>
<td>CODE FOR NAME NEW MEMBER</td>
<td>CODE FOR AVATAR TOP POSTER</td>
<td>CODE FOR POSTS & TOPICS INFO TOP POSTER</td>
</tr>';
The Newest Avatar
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);
Top Ten Posters
// Poster top 10.
$members_result = db_query("
SELECT ID_MEMBER, realName, posts
FROM {$db_prefix}members
WHERE posts > 0
ORDER BY posts DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_posters'] = array();
$max_num_posts = 1;
while ($row_members = mysql_fetch_assoc($members_result))
{
$context['top_posters'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_posts' => $row_members['posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);
if ($max_num_posts < $row_members['posts'])
$max_num_posts = $row_members['posts'];
}
mysql_free_result($members_result);
foreach ($context['top_posters'] as $i => $poster)
$context['top_posters'][$i]['post_percent'] = round(($poster['num_posts'] * 100) / $max_num_posts);
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);
storm runs and hides lol I keep commiting myself to so many projects but i like this one too lol.
I have the block up, but when I added an uploaded image it did not show for some reason.
great job JPG ill test it out today a bit later after i finish my pepsi lol
Yes rebelrose the uploaded avatars are handeled differently according to jocortina who was discussing it in another thread
we may have to dig deeper to get those working as well
ok great thanks akulion
we need jpdeni or eldaka or thurnok or jocortina here :D
arent we shameless? lol
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.
they are so kind to us code challenged people :D
i wonder what we would do without them
Code Challenged, I like that. Yep that is me.
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?
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
That didn't work right for me Fel, this is what I got from that:
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
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.
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).
Well I will look but I have no clue what I am looking for, clueless when it comes to code.
Use my code, you see the (local)avatar, upload avatar or external avatar.
Fel
which code is that Fel?
I think it's this, and a sql fix for it 3 or 4 posts down
http://www.tinyportal.net/smf/index.php?topic=7737.msg74632#msg74632
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" />';
}
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.
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?
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.
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.
Are you sure the latest member has specified an avatar in their profile?
Yes he has uploaded one,
Latest member to SMF means the most recent to register. They might not have even activated their account, yet.
yes he has posted, if I use Fels code it just shows his avatar, if I use the first code it shows a x and the username with link to profile.
Interesting.
Can you check your errorlog real quick and see if there's anything in the last few minutes.
512: loadMemberContext(): member id 57 not previously loaded by loadMemberData()
File: //public_html/forum/Sources/Load.php
Line: 950
Well, let's see if include the Load.php fixes it:
global $memberContext, $sourcedir;
require_once($sourcedir.'/Load.php');
$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>';
It is showing the same as the last code, I have it in a test block on the left hand side, guest can view it if you want to look.
No, that won't do it (or nott he right way if it does happen to work):
global $memberContext;
$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>';
yes thank you so much
how could we do it so it shows the persons posts count and his most recent posts and other info of the user
Quote from: RebelRose on September 28, 2006, 09:38:37 PM
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" />';
}
Replace the last line with ...
if(isset($ava_url))
echo '<div style="text-align:center;"><img src="'. $ava_url .'" alt="" border="0" /><br />' .$context['common_stats']['latest_member']['link']. '</div>';
Fel
Quote from: MeRcChRiS on September 29, 2006, 08:41:09 AM
how could we do it so it shows the persons posts count and his most recent posts and other info of the user
can any one help me on this?
You have to say what "other info of the user" you want. Their complete profile page is only a sinlge click on the displayed name away and this sounds like you're trying to duplicate a lot of profile page information. Additionally, as this is ONLY for the most recent member, their post count would be low or even zero.
Excellent mod. Just made block and it works just fine :up:
Quick question..... is this automatic? Everytime new member arrives,block changes to?
Yes it should
Your most welcome
using jacortina's code from this post (http://www.tinyportal.net/smf/index.php?topic=7737.msg74724#msg74724)
You can alternatively also include an image for no avatar (which I think looks better)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpath-to-peace.net%2Fforum%2Fnoava.gif&hash=18b256714f4b33525b768313e82324e95a99c536)
use this image if u like :)
to do so simply replace in her code the
( No Avatar Yet )
with:
<img src="path to your image">
u can see it workin on my page if u know the way ;)
on a side note:
anyone wana take a crack at this one?
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg175.imageshack.us%2Fimg175%2F3586%2Fmembersblockkb2.gif&hash=d48e8f090dc2e4fd693f7de8a5f5773b1457aacb)
please :D
Quote from: akulion on October 11, 2006, 03:42:50 PM
using jacortina's code from this post (http://www.tinyportal.net/smf/index.php?topic=7737.msg74724#msg74724)
You can alternatively also include an image for no avatar (which I think looks better)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpath-to-peace.net%2Fforum%2Fnoava.gif&hash=18b256714f4b33525b768313e82324e95a99c536)
use this image if u like :)
to do so simply replace in her code the
( No Avatar Yet )
with:
<img src="path to your image">
u can see it workin on my page if u know the way ;)
That is too cool, I have been adding a animated questions mark for those who do not choose an avatar manually, thanks for this tip.
Quote from: akulion on October 11, 2006, 03:46:02 PM
on a side note:
anyone wana take a crack at this one?
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg175.imageshack.us%2Fimg175%2F3586%2Fmembersblockkb2.gif&hash=d48e8f090dc2e4fd693f7de8a5f5773b1457aacb)
please :D
Now that would be cool 8)
Thanks for the 'No Image' pic, I made your image a little smaller ;D
im workin on a horizontal stats display but right now its not lookin that great :P
http://goofy-goobers.com/forum
Quote from: akulion on October 12, 2006, 07:25:47 PM
im workin on a horizontal stats display but right now its not lookin that great :P
http://goofy-goobers.com/forum
I'm sure you can do it! ;D You da man! Oh no the modaholic is coming out of me again.
the avatars pics will only work if they are selected from the list, is there any way to make it to it will show the avatars that people upload?
Quote from: darthmactis on October 16, 2006, 05:57:32 AM
the avatars pics will only work if they are selected from the list, is there any way to make it to it will show the avatars that people upload?
Which code 'snippet' are you using. The one in this message:
http://www.tinyportal.net/smf/index.php?topic=7737.msg74724#msg74724
should show selected, uploaded, or offsite images.
Quote from: jacortina on October 16, 2006, 12:54:23 PM
Quote from: darthmactis on October 16, 2006, 05:57:32 AM
the avatars pics will only work if they are selected from the list, is there any way to make it to it will show the avatars that people upload?
Which code 'snippet' are you using. The one in this message:
http://www.tinyportal.net/smf/index.php?topic=7737.msg74724#msg74724
should show selected, uploaded, or offsite images.
no its was a different code but the one on the page u posted worked great thanks
is there someway to show last X new members ?
Latest members:
ABC + avatar
XYZ + avatar
123 + avatar
No, this code uses prvious supplied latest member data.
Try this:
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>';
}
Thanks :D
ill try it out today
aku
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi26.photobucket.com%2Falbums%2Fc147%2Fjbrowning%2Fchewy.gif&hash=4796439a333fc2cbf1f348b912f4e82ad440b08c)
does anyone have this working with tp 0.9.8 and smf 1.1.2?
i tried the code, but got subs.php error line 238 when using it.
Quote from: jdvarner on April 16, 2007, 02:50:43 PM
does anyone have this working with tp 0.9.8 and smf 1.1.2?
i tried the code, but got subs.php error line 238 when using it.
What version of this are you talking about, I have one on my site that is working, with TP 9.8 and SMF 1.1.2
i guess the original post in the thread from page one. do you mind sharing yours with me?
Quote from: jdvarner on April 17, 2007, 01:11:17 AM
i guess the original post in the thread from page one. do you mind sharing yours with me?
If your talking to me I will be happy to share, I will go get it for you.
Here is one version,
global $memberContext;
$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>';
The one I have calls for a image that I created if they do not choose one. I can post that as well if you like.
This code will put an image of your choice in the block when the newest member does not select an avatar:
global $memberContext;
$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"><img src="path to your image"></img><BR><BR>'.$context['common_stats']['latest_member']['link'].'</div>';
Make sure to replace <img src="path to your image"> with the path to your image you are going to use.
ha ha. figured since the thread was dead, it was obvious i was replying back to you. :)
thank you very much. that worked very good. appreciate it.
jd
Quote from: jdvarner on April 17, 2007, 01:28:03 AM
ha ha. figured since the thread was dead, it was obvious i was replying back to you. :)
thank you very much. that worked very good. appreciate it.
jd
Well you never know sometimes on forum, but I am glad you got what you want.
Your Welcome, we are here to help. :)
Works good for me.
However what i was thinking would be nice if the no avatar image could be clickable wich when clicked take the user to the profile screen to change his avatar
The link that says the user name should do that.
I know that, but i was just wondering if it could be done so the image is a link to
Quote from: Mannie on May 12, 2007, 03:18:18 PM
I know that, but i was just wondering if it could be done so the image is a link to
I think it could, just a matter of getting the code right, I am no coder, but I can try to give it a go later and see what happens, Unless one of the coders come along first and give you the answer.
Thanks, i am no coder either, that is why i asked here ;). In return i will create a pack of avatars soon ;)
Is it possible to restrict this to a specific membergroup?
So say you have a membergroup set up for new people, could this be used to only show the latest members placed in that group? (Would still go off when they registered I spose, but only want to show the one group).
Ok been following all this so far and my question is this.
Using jacortina's code, what needs to be changed to make this show highest poster rather than newest member?
Thx in advance.
If you're using the code from this message:
http://www.tinyportal.net/index.php?topic=7737.msg80797#msg80797
Then you could try...
Changing:
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
To:
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY posts DESC LIMIT ".$count, __FILE__, __LINE__);
Thx for quick reply :)
Just about to head to bed (even though it has gone 5am here heh) so will try that later.
Thx again
Worked like a dream.
Thank you very much :)
gotta say guys i cant get this to work at all
is this PHP?
if so it wont work for me
Can you post the code you are trying to use?
Simply saying, "it wont work" just makes people like me ask.. "Can you post the code?"
And yes, it should be a php block.
im now using this simple 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>';
}
anybody can help me to put other information about the new user like date/time register and their location..
$user_id['registered'] would be the registered date. And location would be $user_id['location']. Add those to your if statement.
if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'<br />',$memberContext['user_id']['registered'],'<br />',$memberContext['user_id']['location'],'</div>';
As that gets its info by calling the loadMemberData() function, you have just about every bit of (standard) information about the member available to you already in the $memberContext array:
$memberContext[$user] = array(
'username' => &$profile['memberName'],
'name' => &$profile['realName'],
'id' => &$profile['ID_MEMBER'],
'is_guest' => $profile['ID_MEMBER'] == 0,
'is_buddy' => $profile['buddy'],
'is_reverse_buddy' => in_array($ID_MEMBER, $buddy_list),
'buddies' => $buddy_list,
'title' => !empty($modSettings['titlesEnable']) ? $profile['usertitle'] : '',
'href' => $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '">' . $profile['realName'] . '</a>',
'email' => &$profile['emailAddress'],
'hide_email' => $profile['emailAddress'] == '' || (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || (!empty($profile['hideEmail']) && !empty($modSettings['allow_hideEmail']) && !allowedTo('moderate_forum') && $ID_MEMBER != $profile['ID_MEMBER']),
'email_public' => (empty($profile['hideEmail']) || empty($modSettings['allow_hideEmail'])) && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']),
'registered' => empty($profile['dateRegistered']) ? $txt[470] : timeformat($profile['dateRegistered']),
'registered_timestamp' => empty($profile['dateRegistered']) ? 0 : forum_time(true, $profile['dateRegistered']),
'blurb' => &$profile['personalText'],
'gender' => array(
'name' => $gendertxt,
'image' => !empty($profile['gender']) ? '<img src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" border="0" />' : ''
),
'website' => array(
'title' => &$profile['websiteTitle'],
'url' => &$profile['websiteUrl'],
),
'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']),
'signature' => &$profile['signature'],
'location' => &$profile['location'],
'icq' => $profile['ICQ'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
'name' => &$profile['ICQ'],
'href' => 'http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'],
'link' => '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $profile['ICQ'] . '" alt="' . $profile['ICQ'] . '" width="18" height="18" border="0" /></a>',
'link_text' => '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $profile['ICQ'] . '" target="_blank">' . $profile['ICQ'] . '</a>',
) : array('name' => '', 'add' => '', 'href' => '', 'link' => '', 'link_text' => ''),
'aim' => $profile['AIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
'name' => &$profile['AIM'],
'href' => 'aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'],
'link' => '<a href="aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $profile['AIM'] . '" border="0" /></a>',
'link_text' => '<a href="aim:goim?screenname=' . urlencode(strtr($profile['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '">' . $profile['AIM'] . '</a>'
) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''),
'yim' => $profile['YIM'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
'name' => &$profile['YIM'],
'href' => 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']),
'link' => '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($profile['YIM']) . '&m=g&t=0" alt="' . $profile['YIM'] . '" border="0" /></a>',
'link_text' => '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($profile['YIM']) . '">' . $profile['YIM'] . '</a>'
) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''),
'msn' => $profile['MSN'] !='' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
'name' => &$profile['MSN'],
'href' => 'http://members.msn.com/' . $profile['MSN'],
'link' => '<a href="http://members.msn.com/' . $profile['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $profile['MSN'] . '" border="0" /></a>',
'link_text' => '<a href="http://members.msn.com/' . $profile['MSN'] . '" target="_blank">' . $profile['MSN'] . '</a>'
) : array('name' => '', 'href' => '', 'link' => '', 'link_text' => ''),
'real_posts' => $profile['posts'],
'posts' => $profile['posts'] > 100000 ? $txt[683] : ($profile['posts'] == 1337 ? 'leet' : comma_format($profile['posts'])),
'avatar' => array(
'name' => &$profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 ? '<img src="' . (empty($profile['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $profile['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['ID_ATTACH'] > 0 ? (empty($profile['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $profile['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),
'last_login' => empty($profile['lastLogin']) ? $txt['never'] : timeformat($profile['lastLogin']),
'last_login_timestamp' => empty($profile['lastLogin']) ? 0 : forum_time(0, $profile['lastLogin']),
'karma' => array(
'good' => &$profile['karmaGood'],
'bad' => &$profile['karmaBad'],
'allow' => !$user_info['is_guest'] && $user_info['posts'] >= $modSettings['karmaMinPosts'] && allowedTo('karma_edit') && !empty($modSettings['karmaMode']) && $ID_MEMBER != $user
),
'ip' => htmlspecialchars($profile['memberIP']),
'ip2' => htmlspecialchars($profile['memberIP2']),
'online' => array(
'is_online' => $profile['is_online'],
'text' => &$txt[$profile['is_online'] ? 'online2' : 'online3'],
'href' => $scripturl . '?action=pm;sa=send;u=' . $profile['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $profile['ID_MEMBER'] . '">' . $txt[$profile['is_online'] ? 'online2' : 'online3'] . '</a>',
'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif',
'label' => &$txt[$profile['is_online'] ? 'online4' : 'online5']
),
'language' => $func['ucwords'](strtr($profile['lngfile'], array('_' => ' ', '-utf8' => ''))),
'is_activated' => isset($profile['is_activated']) ? $profile['is_activated'] : 1,
'is_banned' => isset($profile['is_activated']) ? $profile['is_activated'] >= 10 : 0,
'options' => $profile['options'],
'is_guest' => false,
'group' => $profile['member_group'],
'group_color' => $profile['member_group_color'],
'group_id' => $profile['ID_GROUP'],
'post_group' => $profile['post_group'],
'post_group_color' => $profile['post_group_color'],
'group_stars' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['stars'][1]) ? $settings['images_url'] . '/' . $profile['stars'][1] : '') . '" alt="*" border="0" />', empty($profile['stars'][0]) || empty($profile['stars'][1]) ? 0 : $profile['stars'][0]),
'local_time' => timeformat(time() + ($profile['timeOffset'] - $user_info['time_offset']) * 3600, false),
);
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'].'<br />',$memberContext[$user_id]['registered'],'<br />',$memberContext[$user_id]['location'],'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</div>';
}
not working....
As posted, it should be "$memberContext[$user_id]..." and you put in "$memberContext['user_id']..."
Oops, my mistake. Forgot to make user_id a variable instead of a single element. :)`
Edited your code above.
global $db_prefix, $memberContext;
$count = 1;
$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'].'<br />',$memberContext[$user_id]['registered'],'<br />',$memberContext[$user_id]['location'],'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</div>';
}
the location in not show...
but the date/registered/time/theirname and avatar is ok....
how can resizing the font text and make scrolling....
I would highly suggest taking a lesson in HTML. If look at the <font> and <marquee> tags you can do exactly what you'd like to. Just surround your the line we've been editing with those tags inside the div.
global $db_prefix, $memberContext;
$count = 8;
$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;
echo '
',$a_scroll == 1 ? '<marquee direction = "up" height = 40ex onmouseover=\'this.stop()\' onmouseout=\'this.start()\' scrollamount="2" scrolldelay="0" >' : '','
<div style="width: 100%;',$scroll == 1 ? 'overflow: auto; height: 40ex;' : '','">';
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'].'<br />',$memberContext[$user_id]['registered'],'<br />',$memberContext[$user_id]['location'],'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</div> ',$a_scroll == 1 ? '</marquee>' : '','';
}
i have put the marque...but not run..
I would put the marquee tag inside the div that we have been editing.
global $db_prefix, $memberContext;
$count = 4;
$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"><marquee direction = "up" height = 40ex onmouseover=\'this.stop()\' onmouseout=\'this.start()\' scrollamount="2" scrolldelay="0" >'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'<br />',$memberContext[$user_id]['registered'],'<br />',$memberContext[$user_id]['location'],'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$memberContext[$user_id]['link'].'</marque></div>';
}
that have separate block for each user... how can i make it only one...
You'd have to completely change the code to get it to work that way. Would you like fries and a coke to go with that now? ;) I'll see what I can do if I get some free time tonight.
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.
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?
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.
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.
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.....
$row = mysql_fetch_assoc($result));
Should be:
$row = mysql_fetch_assoc($result);
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.
Okay. Sorry. I shouldn't post things when I'm sick.
AND variable = Member of
should be
AND variable LIKE 'Member of'
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?
You want to have a cup of tea to go aswell :2funny:
There's a lot of variation in the code here. Post yours so I know what I'm starting with.
I was thinking about something that you did for the random users for me:
http://www.tinyportal.net/index.php/topic,19521.new.html#new
I need the code you're using already. I know what you want. I need to know what you have.
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
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>';
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??
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.
Great idea, thanks again!