MyBB Community Forums

Full Version: adding avatar insted of names in portal who is online
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
how to


http://thegame-zone.com/


1- add avatars insted of names on the who is online sidebox on the portal
any help
any help
bumb
bumb

any help
still looking
any help
Hi I have done this exact thing, give me about ten minutes to write it all out and I will tell you how. it is tricky...

Okay, here we go, open portal.php file and save a copy in notepad as a back up, always.

Now in portal.php, look for:
$query = $db->query("
 SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup
 FROM ".TABLE_PREFIX."sessions s
 LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
 WHERE s.time>'$timesearch'
 ORDER BY {$order_by}, {$order_by2}
 ");

and replace with:
$query = $db->query("
 SELECT s.sid, s.ip, s.uid, s.time, s.location, s.location1, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar
 FROM ".TABLE_PREFIX."sessions s
 LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)
 WHERE s.time>'$timesearch'
 ORDER BY {$order_by}, {$order_by2}
 ");


Now look for:
if(($user['invisible'] == 1 && ($mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])) || $user['invisible'] != 1)
 {
 $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
 $user['profilelink'] = get_profile_link($user['uid']);
 eval("\$onlinemembers .= \"".$templates->get("portal_whosonline_memberbit", 1, 0)."\";");
 $comma = $lang->comma;

And replace with:
// Properly format the username and assign the template.
                    // $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                    // $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
                    $user['profilepath'] = $mybb->settings['bburl'] . '/' . get_profile_link($user['uid']);
                    if(!$user['avatar'])
                    {
                        $user['avatar'] = $mybb->settings['bburl'] . '/imgs/images.png';
                    }
                    eval("\$onlinemembers .= \"".$templates->get("portal_whosonline_memberbit", 1, 0)."\";");
                    $comma = $lang->comma;

now go to your template Portal > portal_whosonline_memberbit

and replace all with:
<a href="{$user['profilepath']}"><img src="{$user['avatar']}" /></a>


Note: on the second replacement, the '/imgs/images.png'
is your default avatar so that might be a different file for you, so replace that with your own default avatar url.

Let me know how it goes please!

Also , I have version 8.1 if that makes a difference, I don't know. But it should be okay.

p.s. I can't take full credit for the solution because my method is a variation of this thread: http://community.mybb.com/thread-138762.html
i tried all of this and it gave me a blank page
here is my portal.php
Post a copy of the portal.php that you have changed because a blank page means you have something misplaced, no big deal, lets take a look at what you have done. If you don't have the edited copy, just post a copy of your original portal.php and I will help you get it figured out.
In the mean time, just restore the back up that you have saved.
i have already attached my portal .php on the reply above i hope you can figure it out
thanks
Pages: 1 2