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

Roster Page

Started by londonhogfan, May 31, 2006, 06:56:37 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jacortina

There's nothing currently in that code to get the avatar information (which CAN be a pointer to a standard avatar OR an uploaded avatar - which is stored like an attachment - OR can be a link to an offsite pic.

Once you get that, you can add a column to the table and specify height or width for the image (unfortunately, if you specify both, the graphic will be exactly sized to that without respect to original aspect ratio; if you supply just one, the ratio is maintained - at least in FF and IE). This SHOULD be possible through the 'max-width' and/or 'max-height' parameters, but SOME browsers (*cough* IE *cough*) aren't compliant with the standard.

Dragooon

You simply can do a simple if command in matter of height/width here.
if($row['height'] > xx)
$avatar_height = 150;
else
$avatar_height = $row['height'];

Same with width.

jacortina

And if the actual graphic for the avatar is 300X200 and the space you're allowing for it is 150X150?

You should first check to see which dimension has to be shrunk by the greatest ratio and then apply that ratio to each of the dimensions or you're going to distort the graphic.

Dragooon

Actually yeah, never realized that way.

jacortina

And it kinda requires you to KNOW the avatar's dimensions ;)

Seeing how the code posted shows that 130 pixels are allowed for the avatar column width, supplying a width to the image of 130 (or a centered 126 for a small margin) and leaving out a height specification, will have the browser resize the image in the correct ratio. Yes, the 'taller' pics will demand a greater row height. But it avoids the processing overhead of accessing the graphics library functions.

But, still, the first thing is to get the avatar. And that doesn't HAVE to be in the avatar field of the members table.

The query needs to be changed to:
//Now get all the users
  $query2 = db_query("
     SELECT mem.ID_GROUP, mem.ID_MEMBER, mem.realName, mem.avatar, mem.usertitle,
           mem.emailAddress, mem.hideEmail, mem.lastLogin, mem.location, mem.personalText,
           mem.totalTimeLoggedIn, mem.dateRegistered, mem.ICQ, mem.AIM, mem.YIM, mem.MSN,
           mem.hideEmail, mem.emailAddress, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType
    FROM ({$db_prefix}members AS mem)
    LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
    WHERE ID_GROUP = '" . $groups[$rank]['id'] . "' ", __FILE__, __LINE__);


Then construct the "< img   ... >" specification referring to whichever of the locations the picture is actually located in (I arbitrarily chose 128 as the width to use):
global modSettings;  // add this up top - just a note that it's needed
$av_width = 128;
$avatar_image = ($row2['avatar'] == '' ? ($row2['ID_ATTACH'] > 0 ? '<img  src="' . (empty($row2['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row2['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row2['filename']) . '" alt="" style="width:'.$av_width.';" border="0" />' : '') : (stristr($row2['avatar'], 'http://') ? '<img src="' . $row2['avatar'] . '" alt="" style="width:'.$av_width.';" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row2['avatar']) . '" alt="" style="width:'.$av_width.';" border="0" />'));


That should go after:
      while ($row2 = mysql_fetch_assoc($query2))
      {


Then, find (at end of line - this isn't full line):
<td class="windowbg2">' . '<img src="'.$settings['default_images_url'].'/avatar/'.$row2['avatar'].'.png" />';

Replace with:
<td class="windowbg2">' . $avatar_image;

iGate

#265
every avatar must be within 65 x 65 pixels. so i should have no trouble with ratios as every avatar is within these constrains.

thx for the code above..trying it out now.



Edit:
didn't work

jacortina

Quote from: iGate on December 15, 2007, 10:59:04 AM
Edit:
didn't work

Well, I need more than that if you want help. Avatars not showing up? Sizing not working? What?

Can you post your code WITH the changes given?

iGate

sry i apologise. i should have realised u would need more than that. sry.

http://ihf.lp.pl/index.php?page=27

the error:

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in /srv/4016/www/Sources/Load.php(1735) : eval()'d code(209) : eval()'d code on line 53


the script.

global $db_prefix, $scripturl, $txt, $settings, $options;


// These must be in the order you wish them to print out on your roster.
// VERY IMPORTANT!!!! -- they must be exactly the same as the group names in the database, including
// capitalization and spaces.
$rankorder = array(
  '=IHF= Administrator',
  '=IHF= Forum Global Moderator',
  '=IHF= Forum Moderator',
  '=IHF= Clan Member',
  '=IHF=[r] Clan Recruit',
  );

$groups = '';
//Does all the real work here for showing groups.
$query = db_query("SELECT ID_GROUP, groupName, onlineColor, stars
  FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  $groups[$row['groupName']]  = array(
    'id' => $row['ID_GROUP'],
    'color' => empty($row['onlineColor']) ? '' : $row['onlineColor'],
    'stars' => empty($row['stars']) ? '' : substr($row['stars'],2),
  );
}
mysql_free_result($query);

foreach ($rankorder as $rank)
{
//Now get all the users
  $query2 = db_query("
     SELECT mem.ID_GROUP, mem.ID_MEMBER, mem.realName, mem.avatar, mem.usertitle,
           mem.emailAddress, mem.hideEmail, mem.lastLogin, mem.location, mem.personalText,
           mem.totalTimeLoggedIn, mem.dateRegistered, mem.ICQ, mem.AIM, mem.YIM, mem.MSN,
           mem.hideEmail, mem.emailAddress, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType
    FROM ({$db_prefix}members AS mem)
    LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
    WHERE ID_GROUP = '" . $groups[$rank]['id'] . "' ", __FILE__, __LINE__);
  if(db_affected_rows() != 0)
  {
    echo '<table border="0" cellspacing="1" cellpadding="5" align="center" class="bordercolor">
      <tr><td colspan="7" class="catbg"><font size="4" face="verdana"><b>' . $rank . '</b></font></td></tr>
      <tr><td rowspan="70" width="85" class="profilebg" valign="top">
        <center><img src="' . $settings['images_url'] . '/' . $groups[$rank]['stars'] . '"></center></td>';
      echo '<td class="catinfo" width="270"><b>Name</b></td>';
      echo '<td class="catinfo" width="130"><b>Avatar</b></td>';
      echo '<td class="catinfo" width="170"><b>Last Online</b></td>';
      echo '<td class="catinfo" width="100"><b>Location</b></td>';
      echo '<td class="catinfo" width="175"><b>Contact</b></td></tr><tr>';
      while ($row2 = mysql_fetch_assoc($query2))
      {
global modSettings;  // add this up top - just a note that it's needed
$av_width = 128;
$avatar_image = ($row2['avatar'] == '' ? ($row2['ID_ATTACH'] > 0 ? '<img  src="' . (empty($row2['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row2['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row2['filename']) . '" alt="" style="width:'.$av_width.';" border="0" />' : '') : (stristr($row2['avatar'], 'http://') ? '<img src="' . $row2['avatar'] . '" alt="" style="width:'.$av_width.';" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row2['avatar']) . '" alt="" style="width:'.$av_width.';" border="0" />'));
echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '"><b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b>';

echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $avatar_image;
        echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>';
        echo '<td class="windowbg2" align="center">';
        echo '<i>' . $row2['location'] . '</i>';
        echo '</td><td class="windowbg">';


//Send email row
        if($row2['hideEmail'] == 0)
          echo '<a href="mailto:', $row2['emailAddress'], '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="email" /></a> ';

        if($row2['ICQ'] != '')
          echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $row2['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $row2['ICQ'] . '" alt="' . $row2['ICQ'] . '" width="18" height="18" border="0" /></a> ';
        if($row2['AIM'] != '')
          echo '<a href="aim:goim?screenname=' . urlencode(strtr($row2['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $row2['AIM'] . '" border="0" /></a> ';
        if($row2['YIM'] != '')
          echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row2['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($row2['YIM']) . '&m=g&t=0" alt="' . $row2['YIM'] . '" border="0" /></a> ';
        if($row2['MSN'] != '')
          echo '<a href="http://members.msn.com/' . $row2['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $row2['MSN'] . '" border="0" /></a> ';

//Send PM row
        echo '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $row2['ID_MEMBER'] . '"><img src="' . $settings['images_url'] . '/im_on.gif" alt="email" /></a></a>';
        echo '</td>';
        echo '</tr>';
      }
    echo '</table><br>';
  }
}


thx for ur help so far, and again sry i forgot to post those details...foolish on my part.

iGate

i think it was the last step of ur instruction that i went wrong.

sry for dp.

jacortina

Nope. My error.

This line:
global modSettings;  // add this up top - just a note that it's needed

That should be "$modSettings" (with the "$").

I corrected it and moved it to the top of the script as noted. Try this:
global $db_prefix, $scripturl, $txt, $settings, $options;
global $modSettings;


// These must be in the order you wish them to print out on your roster.
// VERY IMPORTANT!!!! -- they must be exactly the same as the group names in the database, including
// capitalization and spaces.
$rankorder = array(
  '=IHF= Administrator',
  '=IHF= Forum Global Moderator',
  '=IHF= Forum Moderator',
  '=IHF= Clan Member',
  '=IHF=[r] Clan Recruit',
  );

$groups = '';
//Does all the real work here for showing groups.
$query = db_query("SELECT ID_GROUP, groupName, onlineColor, stars
  FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  $groups[$row['groupName']]  = array(
    'id' => $row['ID_GROUP'],
    'color' => empty($row['onlineColor']) ? '' : $row['onlineColor'],
    'stars' => empty($row['stars']) ? '' : substr($row['stars'],2),
  );
}
mysql_free_result($query);

foreach ($rankorder as $rank)
{
//Now get all the users
  $query2 = db_query("
     SELECT mem.ID_GROUP, mem.ID_MEMBER, mem.realName, mem.avatar, mem.usertitle,
           mem.emailAddress, mem.hideEmail, mem.lastLogin, mem.location, mem.personalText,
           mem.totalTimeLoggedIn, mem.dateRegistered, mem.ICQ, mem.AIM, mem.YIM, mem.MSN,
           mem.hideEmail, mem.emailAddress, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType
    FROM ({$db_prefix}members AS mem)
    LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
    WHERE ID_GROUP = '" . $groups[$rank]['id'] . "' ", __FILE__, __LINE__);
  if(db_affected_rows() != 0)
  {
    echo '<table border="0" cellspacing="1" cellpadding="5" align="center" class="bordercolor">
      <tr><td colspan="7" class="catbg"><font size="4" face="verdana"><b>' . $rank . '</b></font></td></tr>
      <tr><td rowspan="70" width="85" class="profilebg" valign="top">
        <center><img src="' . $settings['images_url'] . '/' . $groups[$rank]['stars'] . '"></center></td>';
      echo '<td class="catinfo" width="270"><b>Name</b></td>';
      echo '<td class="catinfo" width="130"><b>Avatar</b></td>';
      echo '<td class="catinfo" width="170"><b>Last Online</b></td>';
      echo '<td class="catinfo" width="100"><b>Location</b></td>';
      echo '<td class="catinfo" width="175"><b>Contact</b></td></tr><tr>';
      while ($row2 = mysql_fetch_assoc($query2))
      {
$av_width = 65;
$avatar_image = ($row2['avatar'] == '' ? ($row2['ID_ATTACH'] > 0 ? '<img  src="' . (empty($row2['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row2['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row2['filename']) . '" alt="" style="width:'.$av_width.';" border="0" />' : '') : (stristr($row2['avatar'], 'http://') ? '<img src="' . $row2['avatar'] . '" alt="" style="width:'.$av_width.';" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row2['avatar']) . '" alt="" style="width:'.$av_width.';" border="0" />'));
echo '<td class="windowbg" height="40"><a href="' . $scripturl . '?action=profile;u=' . $row2['ID_MEMBER'] . '"><b><font color="' . $groups[$rank]['color'] . '" size="3" face="verdana">' . $row2['realName'] . '</b>';

echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $avatar_image;
        echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>';
        echo '<td class="windowbg2" align="center">';
        echo '<i>' . $row2['location'] . '</i>';
        echo '</td><td class="windowbg">';


//Send email row
        if($row2['hideEmail'] == 0)
          echo '<a href="mailto:', $row2['emailAddress'], '"><img src="' . $settings['images_url'] . '/email_sm.gif" alt="email" /></a> ';

        if($row2['ICQ'] != '')
          echo '<a href="http://www.icq.com/whitepages/about_me.php?uin=' . $row2['ICQ'] . '" target="_blank"><img src="http://status.icq.com/online.gif?img=5&icq=' . $row2['ICQ'] . '" alt="' . $row2['ICQ'] . '" width="18" height="18" border="0" /></a> ';
        if($row2['AIM'] != '')
          echo '<a href="aim:goim?screenname=' . urlencode(strtr($row2['AIM'], array(' ' => '%20'))) . '&message=' . $txt['aim_default_message'] . '"><img src="' . $settings['images_url'] . '/aim.gif" alt="' . $row2['AIM'] . '" border="0" /></a> ';
        if($row2['YIM'] != '')
          echo '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row2['YIM']) . '"><img src="http://opi.yahoo.com/online?u=' . urlencode($row2['YIM']) . '&m=g&t=0" alt="' . $row2['YIM'] . '" border="0" /></a> ';
        if($row2['MSN'] != '')
          echo '<a href="http://members.msn.com/' . $row2['MSN'] . '" target="_blank"><img src="' . $settings['images_url'] . '/msntalk.gif" alt="' . $row2['MSN'] . '" border="0" /></a> ';

//Send PM row
        echo '<a href="' . $scripturl . '?action=pm;sa=send;u=' . $row2['ID_MEMBER'] . '"><img src="' . $settings['images_url'] . '/im_on.gif" alt="email" /></a></a>';
        echo '</td>';
        echo '</tr>';
      }
    echo '</table><br>';
  }
}

This website is proudly hosted on Crocweb Cloud Website Hosting.