Hi all,
I used some code from JayBachatero at http://www.tinyportal.net/index.php?topic=19521.0
....to make a really neat latest members block.
global $db_prefix, $memberContext;
// How many members we want?
$count = 7;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<table ALIGN="center">
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
', $member['link'], '
</center></td>';
}
echo '
</tr>
</table>';
$memberContext = array();
Don't forget to amend this line to the location of your own 'no avatar' image.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
Let me know if you decide to use the block ;)
Regards,
Wilsy.
just what i needed thanks :)
what type of block? i tried, script, php and html and get a lot of letters and numbers. :)
It's a PHP block.
Regards,
Wilsy.
thanks Wilsy. I get a parse error from the load.php when used in a php block on front block.
i am guessing a mod i have installed is interfering. Oh well. thanks for this it looks sharp on your example above and im sure many will enjoy it.
jd
Hi,
Try this: -
global $db_prefix, $memberContext;
// How many members we want?
$count = 7;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<table ALIGN="center">
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
', $member['link'], '
</center></td>';
}
echo '
</tr>
</table>';
Regards,
Wilsy.
Thanks Wilsy. That worked. :)
Glad to be of help :)
Regards,
Wilsy.
Is there an easy way to make this code only show the latest members that are part of a specific member group?
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND ID_GROUP= X
where X is your group ID.
hi wilsy. i moved the block around and now it wont center. was curious how i center it.
can be viewed at http://www.jdworld.net
thanks.
jd
Quote from: jdvarner on December 27, 2007, 02:00:31 AM
hi wilsy. i moved the block around and now it wont center. was curious how i center it.
can be viewed at http://www.jdworld.net
thanks.
jd
Hi JD,
Try this: -
global $db_prefix, $memberContext;
// How many members we want?
$count = 8;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<div><table div align="center">
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
',
empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
<div class="smalltext">',$member['link'],'
</div></center></td>';
}
echo '
</tr>
</table></div>';
..don't forget to change this line: -
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
It will also use smaltext for the usernames. It's handy in case you have a few in the block with long ones ;)
Regards,
Wilsy.
As always, Thank You Wilsy. Great stuff, great work, great item. :)
Thanks JD,
I would reset the number of members to 7. I had mine set at 8 but it looks a bit cramped in your block ;)
Regards,
Wilsy.
Thanks for tip. did it. Thanks again.
jd
this cant be right ...
<div><table div align="center">
...and is most likely why it wont center
Quote from: lebisol on December 27, 2007, 04:10:36 PM
this cant be right ...
<div><table div align="center">
...and is most likely why it wont center
Lol lebisol, my bad!
Just seen this , it must have been a late night ;)
Use this instead:
global $db_prefix, $memberContext;
// How many members we want?
$count = 8;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<DIV ALIGN="CENTER">
<table>
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
',
empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
<div class="smalltext">',$member['link'],'
</div></center></td>';
}
echo '
</tr>
</table></div>';
..don't forget to change this line: -
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
That should sort it.
Regards,
Wilsy.
Btw nice work with your site Wilsy, layout is looking better every day especially the user profile section. :up:
thanks for this i got my one just showing the latest member 1 only on a left bloc
Hi .. I would like this to merely list the latest member ids no avatar picture at all. Is that possible and if so .. would you be so kind as to show that code.
I don't understand when you say Don't forget to change this line to my noavat ... either. Perhaps that will be obsolete though when the code is made without avatars requested?/
Thanks again.
just remove:
empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
Ty I would do that if you could tell me where it is I need to remove that portion. From a code snippet or perhaps a file??
Sorry we are talking ignorance on my part ..however I can assure you I do try very hard.
Hi Niagra,
Use this in a block: -
global $db_prefix, $memberContext;
// How many members we want?
$count = 8;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'ID_GROUP IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<DIV ALIGN="CENTER">
<table>
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
',
<div class="smalltext">',$member['link'],'
</div></center></td>';
}
echo '
</tr>
</table></div>';
Regards,
Wilsy.
Can anybody update this code to make it work with SMF2.0.2 and TP1.0 RC3 ?
currently test only blank block appear.
global $smcFunc, $memberContext;
// How many members we want?
$count = 7;
// Just special groups get to be part of the block.
// To select Admins and moderators would be like $groups = array(1, 2);
$groups = array();
// Avatar images.
$avatarImage = 'http://rewindlancs.com/forum/images/noava.gif';
$group_clause = empty($groups) ? '1' : 'id_group IN(' . implode(',', $groups) . ')';
// Lets get the ID's of the members we want.
$request = $smcFunc['db_query']('', '
SELECT id_member FROM {db_prefix}members
WHERE is_activated = 1
ORDER BY id_member DESC LIMIT {int:count}',
array('count' => $count)
);
$members = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$members[] = $row['id_member'];
$smcFunc['db_free_result']($request);
// Load the data for these members.
loadMemberData($members);
// Now get the context.
foreach ($members as $member)
loadMemberContext($member);
echo '
<table align="center">
<tr>';
foreach ($memberContext as $member)
{
echo '
<td><center>
', empty($member['avatar']['image']) ? '<img src="' . $avatarImage . '" />' : str_replace('class="avatar"', 'width="65" height="65" class="avatar"', $member['avatar']['image']), '<br />
', $member['link'], '
</center></td>';
}
echo '
</tr>
</table>';
$memberContext = array();
What about same thing to vertical block? ::)
Just move those <tr> tags inside the foreach loop. :)