PDA

View Full Version : Guest avatar?


dirgotronix
05 Nov 2001, 17:31
How did you do that? I'm tossing ideas about with my forumhome template that uses the avatar, but people with no avatar and guests just see something crappy. I was thinking of adding a row into the customavatars table with userid 0 but I'm afraid that would break something. How did you get the default avatar and avatar for guests?

Chen
05 Nov 2001, 19:54
I put this on index.php:
if ($bbuserinfo['userid']!=0) {
if ($checkavatar=$DB_site->query_first("SELECT filename FROM customavatar WHERE userid='$bbuserinfo[userid]'")) {
$avatarurl='avatar.php?userid='.$bbuserinfo[userid];
} else {
$avatarurl='{imagesfolder}/noavatar.gif';
}
} else {
$avatarurl='{imagesfolder}/guestavatar.gif';
}
Now you use noavatar.gif for users with no avatars, guestavatar.gif for guests (that obviously don't have avatars), and add this to your forumhome template:
<img src="$avatarurl">
That's it. :)

Aracnakat
19 Nov 2001, 06:28
Okie .. first off, thanks for posting this!! Great stuff!

But I do have a question ... I've installed it but I allow folks to either a) Select an Avatar from those present -OR- b) Upload their own.

Currently the hack is only showing up for those who uploaded their own avatar images. Anyone who selected one of our avatars gets the "noavatar.gif" instead of their selected avatar. (Is there a work around for this?)

Also, I thought for guests I would make the "guestavatar.gif" say just "Please Register" ..

In the code below .. is there a way to link that particular image to the registration page? (I tried, but it didn't work).

$avatarurl='{imagesfolder}/guestavatar.gif';

You can check out what I've done at my site: Charr The Grimm Fate Forums (http://forums.charrgrimmfate.com/index.php?referrerid=4).

Thanks in advance for any help, I realize that folks have been buggin' the bejesus out of you and wish that I didn't have to.

~Kat :)

Chen
19 Nov 2001, 06:54
Ok, after you installed the above hack, do this.

Instead of this:
if ($checkavatar=$DB_site->query_first("SELECT filename FROM customavatar WHERE userid='$bbuserinfo[userid]'"))
$avatarurl='avatar.php?userid='.$bbuserinfo[userid];
else
$avatarurl='{imagesfolder}/noavatar.gif';
use ONLY this:
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='{imagesfolder}/noavatar.gif';

Next post will have the link you wanted.

Chen
19 Nov 2001, 06:58
To make the link you wanted, after you installed the above hack, do this.

Instead of this:
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='{imagesfolder}/noavatar.gif';
use this:
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='{imagesfolder}/noavatar.gif';
$avatarimage='<img src="'.$avatarurl.'">';

AND instead of this:
$avatarurl='{imagesfolder}/guestavatar.gif';
use this:
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="{imagesfolder}/guestavatar.gif"></a>';

Now in the template, use this:
$avatarimage
and NOT this:
<img src="$avatarurl">

Aracnakat
19 Nov 2001, 07:16
Wow .. fast and speedy and good stuff! Thank you very very much.

One problem though ... I know this is going to sound totally stupid, but I couldn't figure out how to properly integrate the three templates: forumhome, forumhome_unregmessage & forumhome_welcometext

So I had to do the following .. which I know isn't what you are supposed to do .. but is how I did it to get it to work ;x (FYI: I tried placing the "avatarurl" image code in both the uregmessage & welcometext but they wouldn't show up .. I would get the broken link box for some reason)

forumhome:
<!-- top welcome box -->
<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} width="{contenttablewidth}" align="center"><tr><td>
<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
$welcometext $unregwelcomemessage
<tr>
<td bgcolor="{firstaltcolor}" colspan="5"><smallfont><img src="$avatarurl" align="left">
&nbsp;The time now is $timenow. You last visited: $bbuserinfo[lastvisitdate].<br>
&nbsp;There have been <b>$getnewthread[threads]</b> threads and <b>$getnewpost[posts]</b> posts since your last visit!<br>
&nbsp;$newposts</smallfont></td></tr></table>
<!-- /top welcome box -->
forumhome_unregmessage:
<td bgcolor="{categorybackcolor}" colspan="5"><normalfont color="{categoryfontcolor}"><b>Welcome to the $bbtitle!</b></normalfont><br>
<smallfont color="{categoryfontcolor}">
If this is your first visit, be sure to check out the <a href="misc.php?s=$session[sessionhash]&action=faq"><b>FAQ</b></a>. You may have to <a href="register.php?s=$session[sessionhash]"><b>register</b></a>
before you can post.</smallfont></td></tr>
forumhome_welcometext:
<td bgcolor="{categorybackcolor}" colspan="5"><normalfont color="{categoryfontcolor}"><b>Welcome back $username!</b></normalfont></td>
</tr>

With your instructions for the "registration link" I think I'd need to put the images under forumhome_unregmessage & forumhome_welcometext -- but don't know why my images won't show up.

(NOTE: It's only the images from avatars which were uploaded which don't show up .. the noavatar.gif and guestavatar.gif seemed to work fine).

Any ideas?

Thanks again for your quick and great work .. if there's no work around for the above problem at least I got the selected avatars to work and that's the most important issue of all!

~Kat :)

Chen
19 Nov 2001, 07:48
Help me help you.
In index.php, where did you place the code for the avatar and everything?

Aracnakat
19 Nov 2001, 16:56
Doh! I should have thought to list that last night .. okie I put your code and the code for the # of posts here:

// if user is know, then welcome
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logoutcode')."\";");
eval("\$newposts = \"".gettemplate('forumhome_newposts')."\";");

} else {
$welcometext = "";
eval("\$newposts = \"".gettemplate('forumhome_todayposts')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logincode')."\";");
}
if ($bbuserinfo['userid']!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='{imagesfolder}/noavatar.gif';
} else {
$avatarurl='{imagesfolder}/guestavatar.gif';
}

right above

$birthdaybits="";

I wasn't sure where it went, so that's probably the problem! :)

Thanks again.

Donna

Chen
19 Nov 2001, 17:40
Ok, let me show you something.
This is what you posted:
// if user is know, then welcome
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logoutcode')."\";");
eval("\$newposts = \"".gettemplate('forumhome_newposts')."\";");

} else {
$welcometext = "";
eval("\$newposts = \"".gettemplate('forumhome_todayposts')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logincode')."\";");
}
if ($bbuserinfo['userid']!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='vbimages/noavatar.gif';
} else {
$avatarurl='vbimages/guestavatar.gif';
}

You see that the forumhome_welcometext template is being eval() BEFORE the code for the avatar?
That's why it won't show up in that template, because that template is being "called" before you do the avatar thing.

Anyway, I combined some stuff for you. Use this, instead of that block you posted:
// if user is know, then welcome
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
if ($bbuserinfo['userid']!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='')
$avatarurl='vbimages/noavatar.gif';
$username=$bbuserinfo['username'];
eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logoutcode')."\";");
eval("\$newposts = \"".gettemplate('forumhome_newposts')."\";");
} else {
$avatarurl='vbimages/guestavatar.gif';
$welcometext = "";
eval("\$newposts = \"".gettemplate('forumhome_todayposts')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logincode')."\";");
}

Aracnakat
19 Nov 2001, 21:19
FireFly,

Thank you ever so much for your time! This ended up working out perfectly for me! AND .. I appreciate the little PhP lesson as well since I didn't even realize that it was calling one thing before the other (this will come in handy in the future as I learn PhP).

Thanks again .. it looks awesome and everyone seems to like it very much!

You are wonderful!

Donna :)

Mike Gaidin
21 Nov 2001, 01:06
FireFly, can you release this in the hacks forum. I can't follow your instructions here.

Chen
21 Nov 2001, 08:22
Looks like I'm gonna have to. :)
I will later, it's very simple really, so it shouldn't take me much time.

Thanks Aracnakat! :)

Chen
21 Nov 2001, 11:53
http://www.vbulletin.org/forum/showthread.php?s=&threadid=32560