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

Recent

Welcome to TinyPortal. Please login or sign up.

May 20, 2024, 04:28:32 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,195
  • Total Topics: 21,220
  • Online today: 114
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 66
  • Total: 66

Roster Page

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

goberpiles

Hi I am after some help please, I am really new to this and have read for all of the pages here, I have the same sort of question as one of the above.  I have custom profile fields using Custom Profile Field Mod and I would like to include two of these fields in my roster page.  Curently I have this: http://goberpiles.com/smf/index.php?page=7 the two fields I want to show are 1. PSN name and 2. Team name.

PSN is a playstation network name and team name is a team I will assign to players.  Any ideas on how to get the custom profile fields onto the roster?

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(
  'Prem',
  'Championship',
  'League One',
//  'rank 4',
//  'rank 5',
);

$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 ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN,
           hideEmail, emailAddress
    FROM {$db_prefix}members
    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>PSN</b></td>';
      echo '<td class="catinfo" width="170"><b>LAST ONLINE</b></td>';
      echo '<td class="catinfo" width="120"><b>TEAM</b></td>';
      echo '<td class="catinfo" width="165"><b>CONTACT</b></td></tr><tr>';
      while ($row2 = mysql_fetch_assoc($query2))
      {
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">' . $row2['usertitle'] . '</td>';
        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>';
  }
}

DOOM666

ok im useing JPDeni Roster page i like i but i wont to know i there is a way to show an img instead of the title of the group. the img i have have the title in them.

Thanks,
DOOM666

JPDeni

Rather than make me go through the whole topic to find the code you're using (which I must have written well over a year ago) could you post it, please, using the [ code ] tags. I don't know how the titles are displayed now, which I would need to know in order to tell you how to change them.

DOOM666

here you go sory abou that

global $txt, $scripturl, $user_info, $context, $modSettings, $ID_MEMBER, $board_info, $settings, $db_prefix;

////////////////////////////////////////  Enter the desired groups - in order of appearance, if listing by group
$groups_list = array(13,14);
////////////////////////////////////////

$list_by_group = true;         // 'true' for separate sections by group; 'false' for consolidated list
$include_nonprimary_groups = true;   // 'true' to check for group membership in additional groups; 'false' for primary only
$include_post_groups = false;      // 'true' to include post-count based group in membership search
$include_moderators = false;      // 'true' to include board moderators on page
$repeats_allowed = false;      // 'true' to allow multiple appearances by member on page (for $list_by_group = true only)

$sort_by = 'name';          // choices - 'id' ascending(default), 'posts' descending, 'name' ascending

$extra_type = 'none';         // choices - 'none'(default), 'board' links, 'page' (article) links
///////////////////
// Format - $extra_links['<member userid #>'] = '<forum board #>';
//       or $extra_links['<member userid #>'] = '<TP article #>';
$extra_links = array();
$extra_links['3'] = '5';
$extra_links['2'] = '11';

$extra_label_prefix = 'Page of ';   // text to precede member's name in link label for extra link
$extra_label_suffix = '';      // text to append to member's name in link label for extra link

$page_title = 'Wu Shu Warriors Roster';
$page_subtitle = '';

$moderator_group = '';
///////////////////////////////////////////////////////////////////////////////////////

$sort_ord = 'mem.ID_MEMBER ASC';
if ($sort_by == 'posts') $sort_ord = 'mem.posts DESC';
if ($sort_by == 'name') $sort_ord = 'mem.realName ASC';

if (($extra_type != 'board') && ($extra_type != 'page')) $extra_type = 'none';

if ($include_moderators)
   {if (!in_array($moderator_group, $groups_list)) $groups_list[] = $moderator_group;}

$groups_to_use = array();
if ($list_by_group)
   {$groups_to_use = $groups_list;}
else
   {$groups_to_use[] = 0;}

$users_already_listed = array();
$users_already_listed[] = 0;

loadLanguage('Profile');

echo '<table align="center" width="96%" cellpadding="3" cellspacing="2"><tr>
   <td colspan="4"><h2 align="center">', $page_title, '</h2>
   <span class="smalltext"><h3 align="center">', $page_subtitle, '</h3></span>
</td></tr>';

if (!$list_by_group)
   echo '<tr><td colspan="4">
</td></tr><tr width="95%" style="margin-top: 4px;">
      <td class="windowbg3" colspan="4" style="border-top: 2px solid #d0d0d0; padding-top: 4px; "><h2> </h2>
      </td></tr>';

foreach($groups_to_use as $groupnumber)
{
   $loaded_ids = array();
   $user_profile=array();
   $memberContext=array();
   $profile=array();
   $context['TPortal']['team']=array();
 
   // get the name of the group
   $request = db_query("
      SELECT groupName FROM {$db_prefix}membergroups WHERE ID_GROUP=$groupnumber", __FILE__, __LINE__);
   if(mysql_num_rows($request)>0){
      $row = mysql_fetch_row($request);
      $groupNameX=$row[0];
      mysql_free_result($request);
   }

   if ($list_by_group) {
      $select_where = 'mem.ID_GROUP = '.$groupnumber;
      if ($include_nonprimary_groups) $select_where .= ' OR FIND_IN_SET('.$groupnumber.', mem.additionalGroups)';
      if ($include_post_groups) $select_where .= ' OR mem.ID_POST_GROUP = '.$groupnumber;
      if ($include_moderators && ($groupnumber == $moderator_group)) $select_where = 'mem.ID_MEMBER = m.ID_MEMBER';
   }
   else {
      $select_where = 'mem.ID_GROUP IN (' . implode(', ', $groups_list) . ')';
      if ($include_nonprimary_groups) $select_where .= ' OR FIND_IN_SET(' . implode(', mem.additionalGroups) OR FIND_IN_SET(', $groups_list) . ', mem.additionalGroups)';
      if ($include_post_groups) $select_where .= ' OR mem.ID_POST_GROUP IN (' . implode(', ', $groups_list) . ')';
      if ($include_moderators) $select_where .= 'OR mem.ID_MEMBER = m.ID_MEMBER';
   }

   $select_where = '(' . $select_where . ') AND mem.ID_MEMBER NOT IN (' . implode(', ', $users_already_listed) . ')';

   // Load the member's data.
   $request = db_query("
      SELECT   IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType,
         mem.personalText, mem.avatar, mem.additionalGroups, mem.ID_MEMBER as memnum, mem.memberName, mem.ID_GROUP,
         mem.usertitle, mem.karmaBad, mem.karmaGood, mem.realName, mem.lastLogin, mem.websiteTitle,
         mem.websiteUrl, mem.location, mem.posts, them.value AS teamtext, m.ID_MEMBER as modmem, g.groupName
      FROM ({$db_prefix}members AS mem)
         LEFT JOIN {$db_prefix}moderators AS m ON (m.ID_MEMBER = mem.ID_MEMBER)
         LEFT JOIN {$db_prefix}membergroups AS g ON (g.ID_GROUP = mem.ID_GROUP)
         LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER)
         LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
         LEFT JOIN {$db_prefix}themes AS them ON (mem.ID_MEMBER = them.ID_MEMBER AND them.variable = 'teamtext' AND them.ID_THEME=1)
      WHERE $select_where
      GROUP BY mem.ID_MEMBER
      ORDER BY $sort_ord", __FILE__, __LINE__);
   $new_loaded_ids = array();
   $member_count = 0;

   while ($row = mysql_fetch_assoc($request))
   {
      if (!$repeats_allowed) $users_already_listed[$row['memnum']] = $row['memnum'];

      $member_count += 1;

      $avatar_width = '';
      $avatar_height = '';
      if($context['browser']['is_ie6']) $avatar_width = 'width="' . $modSettings['avatar_max_width_external'] . '"';

      $context['TPortal']['team'][] = array(
         'username' => $row['memberName'],
         'usertitle' => $row['usertitle'],
         'name' => $row['realName'],
         'comment' => $row['comment'],
         'groupname' => ($groupnumber == 0) ? $row['groupName'] : $groupNameX ,
         'posts' => $row['posts'],
         'karmabad' => $row['karmaBad'],
         'karmagood' => $row['karmaGood'],
         'location' => $row['location'],
         'href' => $scripturl . '?action=profile;u=' . $row['memnum'],
         'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['memnum'] . '" title="' . $txt[92] . ' ' . $row['realName'] . '">' . $row['realName'] . '</a>',
         'blurb' => $row['personalText'],
         'avatar' => array(
            'name' => $row['avatar'],
            'image' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? '<img  src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" style="max-height:280px;max-width:180px;" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" style="max-height:280px;max-width:180px;" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" style="max-height:280px;max-width:180px;" border="0" />'),
            'href' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
            'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
         ),
         'last_login' => empty($row['lastLogin']) ? $txt['never'] : timeformat($row['lastLogin']),
         'last_login_timestamp' => empty($row['lastLogin']) ? 0 : forum_time(0, $row['lastLogin']),
         'website' => array(
            'title' => $row['websiteTitle'],
            'url' => $row['websiteUrl']
         ),
         'online' => array(
            'is_online' => $row['isOnline'],
            'text' => &$txt[$row['isOnline'] ? 'online2' : 'online3'],
            'image_href' => $settings['images_url'] . '/' . ($row['isOnline'] ? 'useron' : 'useroff') . '.gif',
         ),
         'teamtext' => $row['teamtext'],
         'member_page' => ($extra_type == 'none') ? '' : empty($extra_links[$row['memnum']]) ? '' : $extra_links[$row['memnum']],
      );

   }
   mysql_free_result($request);

   if ($member_count > 0)
   {
      if ($list_by_group)
      echo '<tr><td colspan="4">
</td></tr><tr width="95%" style="margin-top: 4px;">
         <td class="windowbg3" colspan="4" style="border-top: 2px solid #d0d0d0; padding-top: 4px; "><h2 align="center">' . $groupNameX . '</h2>
         </td></tr>';

      echo '<tr>';
           $newrow=0;

      foreach($context['TPortal']['team'] as $team)
           {
         

         echo '   <td valign="top" class="middletext" style="padding: 2px;">';

            echo '<h2 style="margin-top: 0; margin-bottom: 4px;">'.$team['link'].'</h2>';

            echo ''. $team['usertitle'].'
';

            echo ''. $team['comment'].'
';

            if (!$list_by_group)
               echo ''.$txt[87].': '.$team['groupname'].'
';

            if ($modSettings['karmaMode'] == '1')
               echo '', $modSettings['karmaLabel'], ' ', $team['karmagood'] - $team['karmabad'], '
';
            elseif ($modSettings['karmaMode'] == '2')
               echo '', $modSettings['karmaLabel'], ' +', $team['karmagood'], ' | -', $team['karmabad'], '
';

            echo ''.$txt['lastLoggedIn'].': '.$team['last_login'].'
';



            echo !empty($team['location']) ? ''.$txt[227].': '.$team['location'].'
' : '';

            echo !empty($team['website']['title']) ? ''.$txt[96].': <a href="'.$team['website']['url'].'" target="_blank">'.$team['website']['title'].'</a>
' : '';


            echo !empty($team['blurb']) ? '- '.$team['blurb'].'
' : '';

            echo !empty($team['teamtext']) ? $team['teamtext'].'
' : '';

            if (($extra_type == 'board') && !empty($team['member_page']))
               echo '<a href="' . $scripturl . '?board=' . $team['member_page'] . '">'. $extra_label_prefix . $team['name'] . $extra_label_suffix . '</a>
';
            if (($extra_type == 'page') && !empty($team['member_page']))
               echo '<a href="' . $scripturl . '?page=' . $team['member_page'] . '">'. $extra_label_prefix . $team['name'] . $extra_label_suffix . '</a>
';

         echo '
            </td>';

         $newrow++;
         if($newrow>1){
            $newrow=0;
            echo '</tr><tr><td colspan="4"></td></tr><tr>';
         }
           }
      if($newrow=1) echo '<td colspan="2"></td>';
      echo '</tr>';
   }

}
echo '</table>';

JPDeni

It looks like the code you'll need to change is in the line


         <td class="windowbg3" colspan="4" style="border-top: 2px solid #d0d0d0; padding-top: 4px; "><h2 align="center">' . $groupNameX . '</h2>


and specifically



<h2 align="center">' . $groupNameX . '</h2>



Probably the easiest way to do it is to define your images at the beginning of the script. Something like:



$group_image['group1'] = $settings['images_url'] . '/imagename1.jpg';
$group_image['group2'] = $settings['images_url'] . '/imagename2.jpg';
$group_image['group3'] = $settings['images_url'] . '/imagename3.jpg';



And so on. Make sure that the "group1" etc. is exactly the same as the groups are named, including capitalization. Put all the images in the images directory in your theme.

Then, change



<h2 align="center">' . $groupNameX . '</h2>



to



<img src="' . $group_image[$groupNameX] . '" />


DOOM666

#315
Thanks JP that work. now i have one more ? when i was whating i notice that any time i look a the page the forums creates errors could you help me with that

 
   
http://www.wu-dojo.com/forums/index.php?page=21 
8: Undefined index: 5
File: /home/wudojo/public_html/forums/Themes/default/languages/Profile.english.php (main sub template - eval?)
Line: 158




SMF 1.1.5 TP 1.0.5

JPDeni

Then take out the code. Maybe someone else will have some ideas. I'm not sure of what I'm doing, really, because this wasn't my code to start with.

DOOM666


schnups

#318
I have the same problem as most of the Forum users, I want to include a custom profile field into the roster. I use the same code as the original one posted.  I dont need the NAME field so I replaced it with another name and tried to change the code so it will display a custom profile field text instead of the realname.

I changed the "Name" title to "ingame-name" since Im running a gamer community, but please show me how to add a custom profile field

My Code:
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(
  'Nameless',
  'High Admin',
  'Multi Admin',
  'Infection Admin',
  'KreedZ Admin',
  'Knife Arena Admin',
  'StarWars Admin',
  'GunGame Admin',
);


$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 ID_GROUP, ID_MEMBER, realName, avatar, usertitle,
           emailAddress, hideEmail, lastLogin, location, personalText,
           totalTimeLoggedIn, dateRegistered, ICQ, AIM, YIM, MSN,
           hideEmail, emailAddress
    FROM {$db_prefix}members
    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>GAMING ALIAS</b></td>';
      echo '<td class="catinfo" width="130"><b>NAME</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))
      {
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">' . $row2['usertitle'] . '</td>';
        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>';
  }
}

IchBin

Since we do not have the custom profile fields we cannot possibly show you how to get that field. You should ask the custom profile mod author if you can grab the field some how.