Contribute to the development of SMF. Follow the coding discussions taking place on >> Github.

Team Page for SMF

Mick in Tutorials on Feb 28, 2010
This is a generic "Team Page".


Add code to a PHP article/page


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

/////////////////////////////////////////////////////////////////  Enter the desired groups
   $groups_list = array(1,2);
/////////////////////////////////////////////////////////////////
   $groups_query1 = 'mem.id_group IN ({array_int:groups1})';
   $groups_query2 = '';
//   $groups_query2 = ' OR FIND_IN_SET(' . implode(', mem.additionalGroups) OR FIND_IN_SET(', $groups_list) . ', mem.additionalGroups)';



          echo '<table align="center" width="95%" cellpadding="0" cellspacing="0"><tr>
                <td style="border-bottom: 2px solid #282828; padding-bottom: 2px; "><h2>Our Team</h2>
      <span class="middletext">These are the people you will run into while visiting bluedevilcustoms.com</span><br /><br />
      </td></tr></table>';


   $loaded_ids = array();
    $user_profile=array();
    $memberContext=array();
    $profile=array();
    $context['team']=array();

   // Load the member's data.
      $request = $smcFunc['db_query']('', '
         SELECT IFNULL(lo.log_Time, 0) AS is_online, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type,
            mem.personal_text, mem.avatar, mem.id_member, mem.member_name, mem.real_name , mem.last_login, mem.website_title,
            mem.website_url, mem.location, mem.posts, them.value AS teamtext, g.group_name
         FROM {db_prefix}members AS mem
            INNER JOIN {db_prefix}membergroups AS g ON (mem.id_group = g.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 = {string:theme_var} AND them.ID_THEME=1)
         WHERE (' . $groups_query1 . $groups_query2 . ')
         ORDER BY mem.posts DESC',
         array(
             'groups1' => $groups_list,
             'theme_var' => 'teamtext',
         )
   );
   $new_loaded_ids = array();
   while ($row = mysql_fetch_assoc($request))
   {

         $avatar_width = '';
         $avatar_height = '';

      $context['team'][] = array(
      'username' => $row['member_name'],
      'name' => $row['real_name'],
      'groupname' => $row['group_name'],
      'posts' => $row['posts'],
      'location' => $row['location'],
      'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['real_name'] . '">' . $row['real_name'] . '</a>',
      'blurb' => $row['personal_text'],
      'avatar' => array(
         'name' => $row['avatar'],
         'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img  src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar2" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar2" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar2" 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['last_login']) ? $txt['never'] : timeformat($row['last_login']),
      'last_login_timestamp' => empty($row['last_login']) ? 0 : forum_time(0, $row['last_login']),
      'website' => array(
         'title' => $row['website_title'],
         'url' => $row['website_url']),
      'online' => array(
         'is_online' => $row['is_online'],
         'text' => &$txt[$row['is_online'] ? 'online' : 'offline'],
         'image_href' => $settings['images_url'] . '/' . ($row['is_online'] ? 'useron' : 'useroff') . '.gif',
      ),
      'teamtext' => $row['teamtext'],
   );


   }
   mysql_free_result($request);

   echo '<table align="center" width="95%" cellpadding="5" cellspacing="5" style="margin-top: 10px;"><tr>';

    $newrow=0;
   foreach($context['team'] as $team)
        {
            echo '
<td valign="top" align="right" width="5%">'.$team['avatar']['image'].'</td>
<td valign="top" width="45%" class="windowbg3 team" style="padding: 5px;">
<h2 style="margin-top: 0; margin-bottom: 6px;">'.$team['link'].'</h2>
<b>Position</b>: '.$team['groupname'].'<br />
<b>Last seen</b>: '.$team['last_login'].'<br />
<b>Posts</b>: '.$team['posts'].'<br />
' , !empty($team['location']) ? '<b>Location</b>: '.$team['location'].'<br />' : '' , '
' , !empty($team['website']['title']) ? '<b>Website</b>: <a href="'.$team['website']['url'].'" target="_blank">'.$team['website']['title'].'</a><br />' : '' , '
' ,  $team['online']['is_online'] ? '<img src="'.$team['online']['image_href'].'" alt="" /> '.$team['online']['text'].'<br />' : $team['online']['text'].'<br />' , '

' , !empty($team['blurb']) ? '<i>- '.$team['blurb'].'</i><br />' : '' , '

' ,  !empty($team['teamtext']) ? $team['teamtext'].'<br />' : '' , '

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

Tagged with:


Mick

Mick G

idesignsmf.com

    

Mick is an American theme designer for Simple Machines Forum software currently living in South Florida, USA. He runs idesignSMF and started tinkering with SMF in 2006 where he created several SMF forums of his own before he founded idesignSMF in 2009 to which he is dedicated full time and has a weakness for Tacos and Pizza.


27 Comments

How you you add more group to it? I can only see mine.
1

How you you add more group to it? I can only see mine.

At the top, find:


$groups_list = array(1,2);

and change to whatever groups you wish to add...


$groups_list = array(1,2,3,4,5,6,7,8);
2

Ok, it works. now how do you separate into different category of groups?
Can I give more descriptions to each members like link to blogs, etc...?
3

I have one problem and a question.

When i fill in the avatar width and height restrictions, they don't actually apply. I filled width 150 and height 120 but they stay the same if their too big.

Also, is their a why i can color the members names depending on their group color?
4

I have one problem and a question.

When i fill in the avatar width and height restrictions, they don't actually apply. I filled width 150 and height 120 but they stay the same if their too big.

Also, is their a why i can color the members names depending on their group color?

Hi Acans...

Good question....... ill look at it. ;)
5

Thanks bluedevil :)

Also any news on my color request?
6

Thanks bluedevil :)

Also any news on my color request?

I believe is also doable.  Just need to look at those archived mods to see how they where pulled to show in posts.
7

Hey, just checking in and wondering if you fixed out the avatar restrictions problem?
8

Hey, just checking in and wondering if you fixed out the avatar restrictions problem?

No progress yet.... im having a difficult time with it :o


Im still looking into it. ;)
9

When I add this code to a PHP page SimplePortal, get the following error:

?Un error ha ocurrido!
Hay un error de sintaxis en el c?digo del bloque. Por favor, revisa el c?digo.



Do not edit anything, just copied and pasted it.
10

I can't see the code with my iPhone. I should be home in an hour. ;)
11

I can't see the code with my iPhone. I should be home in an hour. ;)
ok
12

ABM, i tested the code above and it works good.

Make sure the page is PHP ;)   This is for SMF 2.0 only.
13

ABM, i tested the code above and it works good.

Make sure the page is PHP ;)   This is for SMF 2.0 only.
I'm using version 2.0 rc5.

What is the problem?

As a measure to make avatars? 45px wide and 45px high
14




Latest Discussions

Join the conversation

Our Most Popular Features