Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Marcus Forsberg on October 16, 2008, 04:26:12 PM

Title: [Tip] Avatar on Who's Online
Post by: Marcus Forsberg on October 16, 2008, 04:26:12 PM
Hi guys!

This is a simple tip to show how to add avatars to the Who's online list.




Let's begin by opening Who.template.php.

Code (find) Select
<td nowrap="nowrap">', $member['time'], '</td>

Replace whit:

<td nowrap="nowrap">', $member['avatar']['image'], '</td>
<td nowrap="nowrap">', $member['time'], '</td>



That will add the avatar, but is doesn't look very good, does it?
We'll fix this now:

Code (Find) Select
<td colspan="3"><b>', $txt[139], ':</b> ', $context['page_index'], '</td>

Replace whit:
<td colspan="4"><b>', $txt[139], ':</b> ', $context['page_index'], '</td>

That makes it a bit nicer, right?
Not, let's continue whit the last few edits:

Code (Find) Select
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder">

Replace whit:

<table cellpadding="4" cellspacing="0" border="0" width="100%" class="tborder">



Code (Find) Select
<td style="width: 14ex;"><a href="' . $scripturl . '?action=who;start=', $context['start'], ';sort=time', $context['sort_direction'] == 'down' && $context['sort_by'] == 'time' ? ';asc' : '', '">', $txt['who_time'], ' ', $context['sort_by'] == 'time' ? '<img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
<td>', $txt['who_action'], '</td>


Replace whit:

<td>', $txt['avatar'], '</td>
<td style="width: 14ex;"><a href="' . $scripturl . '?action=who;start=', $context['start'], ';sort=time', $context['sort_direction'] == 'down' && $context['sort_by'] == 'time' ? ';asc' : '', '">', $txt['who_time'], ' ', $context['sort_by'] == 'time' ? '<img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
<td>', $txt['who_action'], '</td>





Done whit the template edits. Now remians a small edit in Modifications.english.php.

Code (Add to the end of the file) Select

$txt['avatar'] = 'Avatar';





And we're done. Hope you'll enjoy this.
Title: Re: [Tip] Avatar on Who's Online
Post by: lordtron on October 16, 2008, 05:04:23 PM
Now does this resize the avatar correctly, like if width > height then width = ?? and if height > width then height = ??
Title: Re: [Tip] Avatar on Who's Online
Post by: Marcus Forsberg on October 17, 2008, 10:06:03 AM
It shows the avatar in the same size as it is everywhere else.
Title: Re: [Tip] Avatar on Who's Online
Post by: Marcus Forsberg on October 23, 2008, 10:32:02 AM
By the way, I forgot to ask in the first post, culd someone move this to the Tips and Tricks board, please?
Title: Re: [Tip] Avatar on Who's Online
Post by: Kalina on October 27, 2008, 06:23:39 PM
I added this to my board but now when someone views the who's online page, my error log fills up with this:

8: Undefined index: avatar
File: /home/mydomain/public_html/Themes/default/languages/Who.english.php (main sub template - eval?)
Line: 29
Title: Re: [Tip] Avatar on Who's Online
Post by: Kermit on October 27, 2008, 06:27:24 PM
Quote from: Kalina on October 27, 2008, 06:23:39 PM
I added this to my board but now when someone views the who's online page, my error log fills up with this:

8: Undefined index: avatar
File: /home/mydomain/public_html/Themes/default/languages/Who.english.php (main sub template - eval?)
Line: 29


to fix that,you should do this in Who.template.php.


Code (find) Select

   <td nowrap="nowrap">', $member['avatar']['image'], '</td>


Code (replace with) Select

   <td nowrap="nowrap">', @$member['avatar']['image'], '</td>


Title: Re: [Tip] Avatar on Who's Online
Post by: Kalina on October 27, 2008, 06:54:56 PM
Thanks Duncan, works like a charm!
Title: Re: [Tip] Avatar on Who's Online
Post by: tyhgdgh on October 29, 2008, 08:11:37 PM
8: Undefined index: avatar
File: /var/www/html/forum/Themes/default/languages/modifications.english.php (eval?)
Line: 50


how do i fix this,
Title: Re: [Tip] Avatar on Who's Online
Post by: Kermit on October 30, 2008, 06:17:11 AM
Quote from: Nfanthr33 on October 29, 2008, 08:11:37 PM
8: Undefined index: avatar
File: /var/www/html/forum/Themes/default/languages/modifications.english.php (eval?)
Line: 50


how do i fix this,
Quote from: Nascar on October 16, 2008, 04:26:12 PM


Done whit the template edits. Now remians a small edit in Modifications.english.php.

Code (Add to the end of the file) Select

$txt['avatar'] = 'Avatar';





And we're done. Hope you'll enjoy this.

Did you this in Modifications.english.php ?
Title: Re: [Tip] Avatar on Who's Online
Post by: SpectroPro on October 30, 2008, 09:09:03 AM
When posting tips, could people please post (maybe in the subject) what version of smf the tip is for?  That would be a huge help to those of us that enjoy using the new and better version of SMF rather than the old 1.x versions...  ;)    Sometimes, we have to go through several files, that have the same code, before finding that the tips are for 1.x smf....

Just a thought...
Title: Re: [Tip] Avatar on Who's Online
Post by: tyhgdgh on November 11, 2008, 02:42:02 AM
yes, yes i did, still going bad
Title: Re: [Tip] Avatar on Who's Online
Post by: editor1 on December 06, 2008, 02:12:11 AM
Hi
I was wondering if there was a mod pack that would do the same thing for 1.1.7, if so, what would it be?
thank :)
Title: Re: [Tip] Avatar on Who's Online
Post by: tyhgdgh on December 06, 2008, 04:25:26 AM
There isn't one for now, but there could be one, why? Do you just not want a manual edit????
Title: Re: [Tip] Avatar on Who's Online
Post by: editor1 on December 06, 2008, 04:30:11 AM
Hi, thank you for the response  :) I really appreciate it,
unfortunately I don't know how to install anything manually but would love to learn as it would help immensely.
Title: Re: [Tip] Avatar on Who's Online
Post by: tyhgdgh on December 06, 2008, 04:31:27 AM
I'm not a coder myself, but I'd be glad to do a manual edit for you
Title: Re: [Tip] Avatar on Who's Online
Post by: editor1 on December 06, 2008, 02:15:43 PM
hi
Thank you very much :).. I'd be eternally grateful.
And I appreciate your valuable time, talk soon.
Sincerely, Michael
Title: Re: [Tip] Avatar on Who's Online
Post by: brandonroy on December 20, 2008, 02:28:44 AM
Neat! Just did this with my forum and I used Duncan85's fix for the forum error log problem. I liker it.
Title: Re: [Tip] Avatar on Who's Online
Post by: FlixyaFriend on January 19, 2009, 04:25:15 AM
lol
Thank you very much
Title: Re: [Tip] Avatar on Who's Online
Post by: enjoy1985 on January 20, 2009, 10:01:04 PM
Thank you  ;)
Title: Re: [Tip] Avatar on Who's Online
Post by: Milutin M. on January 30, 2009, 01:44:43 PM
How do i fix this , error . This is my error log :



8: Undefined index: avatar
Datoteka: /home/www/MyDomain/forum/Themes/default/MessageIndex.template.php (main sub template - eval?)
Linija: 58


Thanks
Title: Re: [Tip] Avatar on Who's Online
Post by: Rumbaar on March 10, 2009, 10:43:58 PM
Did you apply Duncan85 fix for the language string in Post #8?

But I think ultimately there might be issues with the avatar call when there are guests involved.  Hence the value isn't populated for a guest and an error is encountered.
Title: Re: [Tip] Avatar on Who's Online
Post by: Yigal on July 04, 2009, 03:17:39 AM
Does this even work for 2.x versions?