TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 219
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 114
  • Total: 114

Latest Members in Front/Centre Block

Started by wilsy, December 02, 2007, 02:53:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wilsy

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.


Sheree


jdvarner

what type of block? i tried, script, php and html and get a lot of letters and numbers. :)

wilsy


jdvarner

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

wilsy

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.

jdvarner


wilsy


astrod00d

Is there an easy way to make this code only show the latest members that are part of a specific member group?

lebisol

SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND ID_GROUP= X

where X is your group ID.

This website is proudly hosted on Crocweb Cloud Website Hosting.