View Full Version : Avatar on homepage
Admin
11-20-2001, 10:00 PM
This is what we use on the main page of this forum.
So many people liked it and asked for it, I posted it on at least 5 threads already, but someone wanted a proper release so here it is. :)
Anyway, in index.php add this:
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarurl='{imagesfolder}/noavatar.gif';
}
$avatarimage='<img src="'.$avatarurl.'">';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="{imagesfolder}/guestavatar.gif"></a>';
}
right after this:
$permissions=getpermissions();
if (!$permissions['canview']) {
show_nopermission();
}
Now in any of your forumhome_xxx templates, you can use this:
$avatarimage
to display the user's avatar.
It will display the user's avatar if he has selected one, if he hasn't selected one it will show noavatar.gif (you'll need to upload that to your images folder), and if it's a guest, it will show guestavatar.gif, and link the image to register.php.
TheComputerGuy
11-21-2001, 12:08 PM
I like it, nice work there Firefly
squawell
11-21-2001, 12:36 PM
it's good hack for me thankz FireFly~~
if i want it show up like main page of this forum what template
should i put this code$avatarimage?
forumhome or .....??
SgtSling
11-21-2001, 01:46 PM
forumhome template
SgtSling
11-21-2001, 01:46 PM
or any of the other's that are listed under forumhome
oh yeah, love'n it firefly!
http://www.form-kaos.com/board/
Sinecure
11-21-2001, 03:00 PM
How would I go about using $avatarimage in my header template. Modifying something in functions.php correct?
Admin
11-21-2001, 03:08 PM
Add the code to global.php, before:
$header='';
Sinecure
11-21-2001, 03:15 PM
Thank You :D
Mike Gaidin
11-21-2001, 08:44 PM
Thanks FireFly!
JTMON
11-22-2001, 06:04 AM
Awesome Hack Firefly. What part of the code would I change to make it so the noavatar.gif is linked to userCP?
Crinos
11-22-2001, 08:55 AM
w00t! Works great! Excellent hack, cheers!
See it in action ;)
http://www.opentechsupport.net/forums/
Admin
11-22-2001, 11:42 AM
[QUOTE]Originally posted by JTMON
Awesome Hack Firefly. What part of the code would I change to make it so the noavatar.gif is linked to userCP?
Is there anyway to encorporate this into a non-vb page?
JTMON
11-22-2001, 11:24 PM
For some reason that code didn't work for me firefly. I just get a red x if I don't have an avatar selected, but no noavatar.gif. I have reuploaded the gif file twice too. Otherwise it works great.
JTMON
11-23-2001, 12:06 AM
ok I got it working now. I had to do this:
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarurl='images/noavatar.gif';
}
$avatarimage='<a href="member.php3?s='.$session[sessionhash].'&action=editavatar"><img src="'.$avatarurl.'">';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="images/guestavatar.gif"></a>';
}
I chose to link right into the edit avatar spot instead but I had tack on the code you gave me to the beginning of:
$avatarimage'<img src="'.$avatarurl.'">';
JTMON
11-23-2001, 02:17 AM
hmm, the only problem now is I have a box around the avatar?
Try changing <img src="'.$avatarurl.'">
to<img src="'.$avatarurl.'" border="0">
JTMON
11-23-2001, 03:51 AM
Thanks Bane!! Worked perfectly!:D
Jakeman
11-26-2001, 04:18 AM
hey Crinos (Tolitz i presume?), gimme your forumhome template. i want your table layout for the top box with the ava in it... i'm having brain farts here. :stupid: :D
Crinos
11-26-2001, 06:13 AM
LOL, I wish it was that easy - the whole process of putting it together is scattered althroughout several templates:
forumhome
forumhome_unregmessage
forumhome_welcometext
forumhome_logincode
forumhome_logoutcode
forumhome_pmloggedin
I'm afraid giving you just the forumhome template is not gonna be useful ;)
Took me about 3-4 hours of trial and error just trying to put it together ... what I did was set up a "mock-up" page with the layout as I want it to be ... then I just insert the relevant code and then chop it up by the <tr>'s and insert each one in the templates I mentioned :D
Jakeman
11-26-2001, 06:43 AM
oic. ok then... i'll manage :)
trilOByte
11-26-2001, 08:48 AM
Hey man, I think I just posted what you are looking for. I installed it all together, then wrote a walkthrough of most of it for a friend, thought someone might find it usefull, so uploaded the zip here...
https://vborg.vbsupport.ru/showthread.php?s=&threadid=32702
See my sig for a working example.
Even if it's not exactly what you are looking for, it should give you the *bones* to play with!
trilOByte
11-26-2001, 08:51 AM
Thinking about it, I prolly should have posted it here - not sure about the protocol for such things :rolleyes:
Anyway, I *think* I included all the edits :rolleyes: :rolleyes: :D :D
Jakeman
11-27-2001, 02:06 AM
thanks :)
Jakeman
11-27-2001, 06:13 PM
cool... check out my www link
fiona
11-30-2001, 04:10 PM
Originally posted by JTMON
For some reason that code didn't work for me firefly. I just get a red x if I don't have an avatar selected, but no noavatar.gif. I have reuploaded the gif file twice too. Otherwise it works great.
have you checked the path to the image matches with what you have in index.php
ie mine is images/noavatar.gif
but in the code given by Firefly its
<img src="vbimages/noavatar.gif">
i had the same problem :D
Gamingforce
11-30-2001, 04:50 PM
Really nice hack Firefly. I would install it but the default avatar size for our message board is 105x150 making the avatar take up too much board real estate. Awesome job though Firefly!
JTMON
11-30-2001, 09:10 PM
Originally posted by fiona
i had the same problem :D
Well it's been images for me this whole time. I never saw vbimages. I changed the coding so if they don't have an avatar it gives them the no avatar but it's also linked to the edit avatar page:D
westi
12-02-2001, 12:59 PM
Hi,
Originally posted by Matt
Is there anyway to encorporate this into a non-vb page?
include the follow global.php to your page...
<?
// global.php
// Diese Datei ist f?r Webseiten die auf Funktionen eines vBulletin zugreifen
// wollen.
// Autor: westi (westi@ftpworld.org)
// Stand: v1.0 / 2001-12-02
$boardpath="/path/to/the/board";
unset($dbservertype);
//load config
require("$boardpath/admin/config.php");
require("$boardpath/admin/functions.php");
// init db **********************
// load db class
$dbservertype = strtolower($dbservertype);
$dbclassname="$boardpath/admin/db_$dbservertype.php";
require($dbclassname);
$DB_site=new DB_Sql_vb;
$DB_site->appname="vBulletin Control Panel";
$DB_site->appshortname="vBulletin (cp)";
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;
$DB_site->connect();
$dbpassword="";
$DB_site->password="";
// end init db
// load options
$optionstemp=$DB_site->query_first("SELECT template FROM template WHERE title='options'");
eval($optionstemp[template]);
// ################ END INIT #################
if ($bbuserid!="") {
$user=getuserinfo($bbuserid);
$username=$user[username];
$lastday=vbdate($dateformat,$user[lastvisit]+3600);
$lasttime=vbdate($timeformat,$user[lastvisit]+3600);
$templatesetid=$DB_site->query_first("SELECT templatesetid AS templatesetid FROM style WHERE styleid=$user[styleid]");
$templatesetid=$templatesetid[templatesetid];
$avatarurl=getavatarurl($user[userid]);
if ($avatarurl=='') {
$avatarurl='images/noavatar.gif';
}
$avatarimage='<a href="'.$bburl.'/member.php3?action=editavatar"><img src="'.$bburl.'/'.$avatarurl.'" border="0"></a>';
} else {
$avatarimage='<a href="'.$bburl.'/register.php?action=signup"><img src="'.$bburl.'/images/guestavatar.gif" border="0"></a>';
}
}
?>
greets,
westi
Airwaves
12-02-2001, 08:24 PM
Where do I put
$avatarimage
to place it in the same place as on vb.org main forum page?
Airwaves
12-03-2001, 07:27 PM
Bump
cant anyone help a n00b ?
JTMON
12-03-2001, 09:10 PM
in the forumhome template, right above $postbits :D
Airwaves
12-04-2001, 06:48 AM
I cannot find $postbits in the forumdisplay template ??
Lesane
12-04-2001, 07:16 AM
Put it in the forumhome template like Firefly said in his first post!
Bedhead
12-04-2001, 10:04 AM
I have done everything step by step, but where exactly does $avatarimage go in the forumhome template.
Bedhead
12-04-2001, 10:05 AM
If it is installed here, how come i don't have it as noavater here as i have not selected one here?
Confused.
Bedhead
12-04-2001, 10:31 AM
I got it.
I thought this hack would add it to each member in the posts.
It is only on the main page.
Okay.
JTMON
12-04-2001, 10:55 AM
Originally posted by Bedhead
I got it.
I thought this hack would add it to each member in the posts.
It is only on the main page.
Okay.
Each member already has his avatar in his post...?
Airwaves
12-04-2001, 08:00 PM
Having a bit of trouble with this...
I have the two image required in the /forums/images/avatars folder on my server, BUT, i still get a little red X in a box for someone who doesnt have an avatar set
here is the code in my index.php
//avatar images
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarimage='<a href="usercp.php?s='.$session[sessionhash].'"><img border="0" src="images/avatars/noavatar.gif"></a>';
}
$avatarimage='<img border="0" src="'.$avatarurl.'">';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img border="0" src="images/avatars/guestavatar.gif"></a>';
}
//end avatar images
I used a few fixes from the rest of this thread like removing the borders and making it linkk to the usercp to set an avatar.
please help?
JTMON
12-04-2001, 08:21 PM
Well here is my altered code that works for me. Note, I didn't care about the guest code as I don't allow guests to view my board:D
//Avatar on Homepage Code
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarurl='images/noavatar.gif';
}
$avatarimage='<a href="member.php?s='.$session[sessionhash].'&action=editavatar"><img src="'.$avatarurl.'" border="0"></a>';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="images/guestavatar.gif"></a>';
}
Airwaves
12-04-2001, 08:27 PM
well php3 are of no use to me, i have .php
also, i allow guests to view, so thats no use to me either :(
sorry
JTMON
12-04-2001, 08:35 PM
Originally posted by Airwaves
well php3 are of no use to me, i have .php
also, i allow guests to view, so thats no use to me either :(
sorry
You can use it with no problems. There is no difference other than the extension in the link in the code. I've edited them out now so you should just be able to cut and paste it in and it will work.
Airwaves
12-05-2001, 05:05 AM
Your code doesnt hyperlink to the UserCP when they have no avatar specified.
I will use your code for now, but I really would like that feature.
trilOByte
12-05-2001, 05:25 AM
Originally posted by Airwaves
Having a bit of trouble with this...
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img border="0" src="images/avatars/guestavatar.gif"></a>';
Try making the paths absolute for guestavatar.gif and noavatar.gif - ie,
src="http://www.yoursite.com/forums/images/avatars/guestavatar.gif"></a>';
etc....
JTMON
12-05-2001, 11:04 AM
Originally posted by Airwaves
Your code doesnt hyperlink to the UserCP when they have no avatar specified.
I will use your code for now, but I really would like that feature.
It does for me :rolleyes:
VolsReport
12-06-2001, 01:08 AM
Does it work for v2.03?
Airwaves
12-06-2001, 08:53 AM
Originally posted by JTMON
It does for me :rolleyes:
Yeah sorry, not being a PHP/HTML guru, I didnt realise until I made a test account.
Anyway, thanks for your help, I now have it sorted. :D
take a look at http://www.airwavescomms.co.uk/forums
Lesane
12-06-2001, 09:20 AM
Originally posted by VolsReport
Does it work for v2.03?
Yes
Dark Blaze
12-06-2001, 10:41 AM
Great Hack Chen, well done :)
JTMON
12-06-2001, 10:43 AM
Originally posted by Airwaves
Yeah sorry, not being a PHP/HTML guru, I didnt realise until I made a test account.
Anyway, thanks for your help, I now have it sorted. :D
take a look at http://www.airwavescomms.co.uk/forums
Looking Good
VolsReport
12-06-2001, 06:05 PM
Originally posted by Lesane
Yes
Thanx...Ima add it now...
TechTalk
12-15-2001, 10:03 PM
What if the user has uploaded their own avatar (goes into the customavatar table in DB) How can we make that show up?
Admin
12-16-2001, 11:30 AM
[QUOTE]Originally posted by TechTalk
What if the user has uploaded their own avatar (goes into the customavatar table in DB) How can we make that show up?
TechTalk
12-16-2001, 01:48 PM
It sure does :) I was having errors that were causing me problems.
A note to evryone else.... if you use this hack in global.php like I did your users will have problem uploading their avatar (real nasty error). I posted on it here:
http://www.vbulletin.com/forum/showthread.php?threadid=35489
The only solution I could find was to change the variable names from "$avatarurl" and "$avatarimage" to "$theavatarimage" and "$theavatarurl"
Im not sure if the original variables were already in use by Vb or what, but it was causing me loads of problems.
zajako
04-01-2002, 04:45 AM
umm is there anything simialr to make it so the profile fields can be used on teh index page. an ex is I want a custom field to be displayed under the avatar.
Admin
04-01-2002, 05:03 AM
Just stick $bbuserinfo[field7] for example in the template.
zajako
04-01-2002, 04:15 PM
ok, i tried that... but there is a problem.
if ($bbuserinfo[userid]!=0) {
$hpmax=getavatarurl($bbuserinfo[field7]);
if ($hpmax=='') {
$hpmax='0';
}
}
THe function for getavatarurl I know.
but what would be the get function used for field 7 and so on.
Right now it just ignores my variable for $hpmax
Admin
04-01-2002, 04:21 PM
Huh? Why do try to get an avatar for the field7 as a userid? If you just want to display field7, stick $bbuserinfo[field7].
zajako
04-01-2002, 05:44 PM
Originally posted by FireFly
Just stick $bbuserinfo[field7] for example in the template.
you said stick into the template I though you meant the avatar templet you made.....
awesome it worked thanks so much.
Platinum [JSI]
05-17-2002, 09:50 PM
the $avatarimage bit isnt working for me, ive added the code to the index.php and added $avatarimage where i want it but i get no image, am i missing some code somewhere?
Admin
05-18-2002, 06:20 AM
Where did you add $avatarimage?
ceo_tfw
05-27-2002, 07:33 AM
works great on mine and thanks, I have a question?
I would like to have more user info on the main page (index page) like how many posts they have made, there awards, threads they have replied to and their posts made in that day,
can anyone help me
mrdave
06-26-2002, 05:27 PM
Please help, the problem is in the new avatar.php
pharcyde
07-07-2002, 12:35 AM
firefly, is there a script that will make it work with 2.2.6???
Admin
07-07-2002, 02:11 PM
What error are you getting when trying to use it with 2.2.6?
pharcyde
07-07-2002, 09:07 PM
the avatar wont show up at all... www.turbine7.com in the "aeternalis" skin and the others that use the welcome panel hack
iblis
07-21-2002, 11:18 AM
Im using vbhome, anyone know how to add this to my index site?
Kuipo
11-03-2002, 12:34 PM
Im useing an off site avatar hack too, so the url is stored in a field (field7)
i trid to change this:
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarurl='images/avatars/noavatar.gif';
}
to this:
if ($bbuserinfo[userid]!=0) {
$avatarurl=$bbuserinfo[field7];
if ($avatarurl=='') {
$avatarurl='images/avatars/noavatar.gif';
}
But it doesnt seem to be working, is there somthing im doing wrong?
Esdee
11-24-2002, 11:37 AM
Hiya
I love your hack, but I have a huge problem with it.
I'm using Vb2.2.8 and the noavatar isn't showing. I just get a red X. The guestavatar works perfectly. I checked the path multiple times and it is correct.
Here's my code
Please help me, someone :(
if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarimage='<a href="usercp.php?s='.$session[sessionhash].'"><img src="images/avatars/noavatar.jpg" border="0"></a>';
}
$avatarimage='<img src="'.$avatarurl.'">';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="images/avatars/guestavatar.jpg" border="0"></a>';
}
212rikanmofo
04-19-2003, 09:51 AM
firefly how would i incorporate this into my postbit template... i want it to show a noavatar.gif when a user doesnt have one selected for my postbit template, how would i do that?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.