vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin.org Site Feedback (https://vborg.vbsupport.ru/forumdisplay.php?f=7)
-   -   Guest avatar? (https://vborg.vbsupport.ru/showthread.php?t=32153)

dirgotronix 11-05-2001 04:31 PM

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?

Admin 11-05-2001 06:54 PM

I put this on index.php:
PHP Code:

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='{[i][/i]imagesfolder}/noavatar.gif';
  }
} else {
  
$avatarurl='{[i][/i]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:
Code:

<img src="$avatarurl">
That's it. :)

Aracnakat 11-19-2001 05:28 AM

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).

PHP Code:

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

You can check out what I've done at my site: Charr The Grimm Fate Forums.

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 :)

Admin 11-19-2001 05:54 AM

Ok, after you installed the above hack, do this.

Instead of this:
Code:

  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:
Code:

  $avatarurl=getavatarurl($bbuserinfo[userid]);
  if ($avatarurl=='')
    $avatarurl='{imagesfolder}/noavatar.gif';

Next post will have the link you wanted.

Admin 11-19-2001 05:58 AM

To make the link you wanted, after you installed the above hack, do this.

Instead of this:
Code:

  $avatarurl=getavatarurl($bbuserinfo[userid]);
  if ($avatarurl=='')
    $avatarurl='{imagesfolder}/noavatar.gif';

use this:
Code:

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

AND instead of this:
Code:

  $avatarurl='{imagesfolder}/guestavatar.gif';
use this:
Code:

  $avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="{imagesfolder}/guestavatar.gif"></a>';
Now in the template, use this:
Code:

$avatarimage
and NOT this:
Code:

<img src="$avatarurl">

Aracnakat 11-19-2001 06:16 AM

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:
Code:

<!-- 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:
Code:

<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:
Code:

<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 :)

Admin 11-19-2001 06:48 AM

Help me help you.
In index.php, where did you place the code for the avatar and everything?

Aracnakat 11-19-2001 03:56 PM

Doh! I should have thought to list that last night .. okie I put your code and the code for the # of posts here:

Code:

// 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

Code:

$birthdaybits="";
I wasn't sure where it went, so that's probably the problem! :)

Thanks again.

Donna

Admin 11-19-2001 04:40 PM

Ok, let me show you something.
This is what you posted:
Code:

// 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:
Code:

// 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 11-19-2001 08:19 PM

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 :)


All times are GMT. The time now is 08:52 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01092 seconds
  • Memory Usage 1,786KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (16)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete