Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 981
  • Dot Hidden: 0
  • Dot Users: 1
  • Dot Users Online:

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Default Avatar if NULL

Started by Largo_npc, August 13, 2009, 11:16:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Largo_npc

I've managed to hack in some code to SMF so that if a user doesn't have an Avatar, they are given a default one depending on their group.

Here's the code I used:
// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
<li class="margintop" style="overflow: auto;">', $message['member']['avatar']['image'], '</li>';
else
{
switch($message['member']['group_id'])
{
case 1 : $npc_ava = "default_avatars/elder.gif"; break;
case 2 : $npc_ava = "default_avatars/council.gif"; break;
case 9 : $npc_ava = "default_avatars/member.gif"; break;
case 11 : $npc_ava = "default_avatars/srmember.gif"; break;
case 10 : $npc_ava = "default_avatars/trialee.gif"; break;
default : $npc_ava = "default_avatars/newb.gif";
}

echo '
<li class="margintop" style="overflow: auto;"><img src="',  $npc_ava , '" alt="" \></li>';
}


I've managed to get it working for User Info block on the portal (Version 2.3 btw) but I'm stuck for getting it to work elsewhere, like in Top Posters, News Posts and Staff blocks.
Here's the altered version for User Info.
// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
', $message['member']['avatar']['image'], '<br \>';
else
{
switch($member_info['group_id'])
{
case 1 : $npc_ava = "default_avatars/elder.gif"; break;
case 2 : $npc_ava = "default_avatars/council.gif"; break;
case 9 : $npc_ava = "default_avatars/member.gif"; break;
case 11 : $npc_ava = "default_avatars/srmember.gif"; break;
case 10 : $npc_ava = "default_avatars/trialee.gif"; break;
default : $npc_ava = "default_avatars/newb.gif";
}

echo '
<img src="',  $npc_ava , '" alt="" \><br \>';
}


Any ideas how I can resolve this? I need to some how pick up if the avatar field is empty, and if so then use the correct image for the group and resize if needed.

I'm a C\C++ guy, so I only know very limited and basic PHP and SQL.

Cheers

Largo_npc

Nevermind, fixed it.

I was looking at where the requests from the database were assigned. I looked a bit further on and just used the same method plus adding in a new request for group ID and it worked.