creating a new theme and need some help displaying
the anonymous / user avatar in the header of the site.
Not sure how to code it. I have looked at some similar code
within the forums, but it seems to call variables differently.
Can anyone help me get started, pointed in the right direction?
Is this process similar to coding the avatar in Blocks?
If you look at it, you will notice a pasty green box in the
header, this is where I want the avatar to go.
Side note: How do you like my first theme?
still working on the forum part.
_________________ ~Implosion at it's best!
disgruntledtech Site Admin
Joined: Apr 14, 2003
Posts: 991
Location: Tulsa, OK
Posted:
Mon Jul 14, 2003 12:02 am
theme looks good -keep in mind users with big avatars could break that header -either hardcode the height/width into the img tag or make that table resizeable
heres a bit of code that'll do the trick
Code:
global $user, $cookie, $prefix;
//get username
cookiedecode($user);
$username = $cookie[1];
if ($username == "") {
$userinfo[user_avatar] = 'blank.gif';
$userinfo[user_avatar_type] = 1;
} else {
$sql = "SELECT user_avatar, user_avatar_type FROM ".$user_prefix."_users WHERE username='$username'";
if( !($result = $db->sql_query($sql)) ) {
//query was not successfull - set avatar to blank and report error in a html comment for debug purposes
$userinfo[user_avatar] = 'blank.gif';
$userinfo[user_avatar_type] = 1;
echo "<!--";
message_die(CRITICAL_ERROR, "Could not query user information", "", __LINE__, __FILE__, $bbsql);
echo "-->";
}
$num = $db->sql_numrows($result);
$userinfo = $db->sql_fetchrow($result);
}
//get avatar path info
$bbsql = "SELECT avatar_path, avatar_gallery_path FROM ".$prefix."_bbconfig";
if( !($bbresult = $db->sql_query($bbsql)) ) {
//query was not successfull - set paths to default and report error in a html comment for debug purposes
$board_config[avatar_path] = 'modules/Forums/images/avatars';
$board_config[avatar_gallery_path] = 'modules/Forums/images/avatars/gallery';
echo "<!--";
message_die(CRITICAL_ERROR, "Could not query avatar path information", "", __LINE__, __FILE__, $bbsql);
echo "-->";
}
while ( $row = $db->sql_fetchrow($bbresult) ) {
$board_config[$row['config_name']] = $row['config_value'];
}
switch ($userinfo[user_avatar_type]) {
case 1:
$display_avatar = $board_config[avatar_path]."/".$userinfo[user_avatar];
break;
case 2:
$display_avatar = $userinfo[user_avatar];
break;
case 3:
$display_avatar = $board_config[avatar_gallery_path]."/".$userinfo[user_avatar];
break;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum