View Full Version : Show User's Avatar in Navbar v1.1
fraghappy
06-13-2005, 10:00 PM
This is my first plugin for vB. It took me awhile to figure things out, but, once I polished it down, it was a piece of cake. If you encounter any problems or have any suggestions, please let me know, thanks!
IF YOU HAVE VERSION 1.0 INSTALLED, please update to the most recent version (1.1). This is because of a necessary bugfix needed to prevent users who do not have avatars from having image problems!
-------------------
[3.5.x] Show User's Avatar in Navbar
Designed and Coded by: Thorne N. Melcher ("Frag")
Version: 1.1 (released 6/14/05)
Screenshots: 1; included in the .zip file.
Description: This hack will display the user's avatar next to the "Welcome, {username}" message in the navbar at the top of every page. If there is no user presently logged in, the plugin will not bother to query the database, and the avatar will not display.
Plugin ?2005 The Whispering Realms Studios.
Performance and Installation Specs
Supports vB versions: 3.5.x
New Queries: 1 per pageload, IF the user is logged in.
New Hook Calls: 1 (global_start)
New Files: 1 (/images/misc/noavatar.gif)
Template Modifications: 1 ('navbar')
File Edits: none
Included Files
avatar_on_navbar.xml - Plugin file
README.html - Installation instructions.
screenshot.jpg - Screenshot of the plugin in action.
/UPLOAD/images/misc/noavatar.gif - Default "No Avatar" image.
Version History
v1.1 (6.14.05) - A bug was indentified where, if the user viewing the page did not have an avatar uploaded/selected, it would try to display his or her avatar anyway.
New files: /images/misc/newavatar.gif
Changed files: /avatar_on_navbar.xml
v1.0 (6.14.05) - The first public release, complete with all necessary features.
Please click "Install" if you decide to use this plugin! Thank you!
FleaBag
06-14-2005, 03:40 PM
Very nice! Have been wanting something to make the navbar look a little less boring for some time. Will surely install when I make the leap to 3.5. :)
dreck
06-14-2005, 03:57 PM
Yes, very nice! This will come in handy when i upgrade to 3.5.
Also would be nice to have new & subscribed posts below the private messages.
Just a thought!
Thanks!
You could get rid of that one query per page by simply adding:
define('AVATAR_ON_NAVBAR', 1); to the /includes/config.php file
Chris M
06-14-2005, 05:27 PM
That would take away the point of this being a "plugin" though ;)
Satan
That would take away the point of this being a "plugin" though ;)
Satan
Exactly, but you its always better to avoid adding unneeded queries. ;)
I would release my version of this hack in the coding section if fraghappy doesnt mind. :)
fraghappy
06-14-2005, 07:52 PM
Yes, very nice! This will come in handy when i upgrade to 3.5.
Also would be nice to have new & subscribed posts below the private messages.
Just a thought!
Thanks!
I'll create a plugin based off of this called "Navbar Plus" or something. Look for it later tonight/early tomorrow.
Exactly, but you its always better to avoid adding unneeded queries. ;)
I would release my version of this hack in the coding section if fraghappy doesnt mind. :)
I'm really uptight about people stealing my work and not giving me credit. Thank you for asking, that really makes the difference to me. Please, in your post on vB.org and in the hack, please give mention of both me and this hack. I really don't mind people editing what I do, that's what's nice about open-source language. I'm just glad that you aren't going to steal me work and take the credit. :D Go for it!
Kirk Y
06-14-2005, 09:04 PM
When the user logged in doesn't have an avatar set, it shows that lovely red x box, would there be anyway to set it to go to a certain say, No Avatar Selected Image, if the user doesn't have an avatar set?
fraghappy
06-14-2005, 09:17 PM
When the user logged in doesn't have an avatar set, it shows that lovely red x box, would there be anyway to set it to go to a certain say, No Avatar Selected Image, if the user doesn't have an avatar set?
I'll update it for you later tonight. Thanks for letting me know about that.
Kirk Y
06-14-2005, 09:19 PM
No problem. Thanks for updating! :)
fraghappy
06-14-2005, 11:34 PM
Version 1.1 has been released in order to address the following bug:
When the user logged in doesn't have an avatar set, it shows that lovely red x box, would there be anyway to set it to go to a certain say, No Avatar Selected Image, if the user doesn't have an avatar set?
The .zip file has been updated and includes everything that you'll need to upgrade to the latest version. Thank you for showing so much interest in my hack. If you find any other bugs or have any other suggestions, please let me know!
ThorstenA
06-15-2005, 08:40 AM
Very nice.
Suggestions:
* smaller image size that fits to navbar & nice blue border: <img ..... height="37" border="1">
* put image and text more together: <table cellpadding="1" ...>
mholtum
06-16-2005, 02:33 AM
Thank you for the update. I used a different "No Avatar" image than the provided one. If anyone would like to use mine, see the attached image. Also, I didn't like the way the avatar was positioned, it stretched my forum's header too much, instead of the html provided for the "navbar" template, I placed the avatar in a seperate table. For whatever reason the avatar was displayed above the userinfo, instead of beside it. So I used this html:
<if condition="$bbuserinfo['userid']">
<td class="alt2" valign="left" nowrap="nowrap">
<a href="profile.php?$session[sessionurl]do=editavatar"><img src="$navbar_ava[0]" alt="Your avatar" border="0" /></a></td>
<td class="alt2" valign="right" nowrap="nowrap">
<div class="smallfont">
<strong><phrase 1="$bbuserinfo[username]">$vbphrase[welcome_x]</phrase></strong><br />
<phrase 1="$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
<if condition="$show['pmstats']"><br /><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl]">$vbphrase[private_messages_nav]</phrase></if>
</div>
</td>
I've also attached a screenshot of what my html looks like on the navbar.
Thanks again for the hack, Frag.I would like to use your code but I get this error:
The following error occurred when attempting to evaluate this template:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mholtum/public_html/test/includes/adminfunctions_template.php(3515) : eval()'d code on line 181
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
fraghappy
06-16-2005, 04:55 PM
I would like to use your code but I get this error:
The following error occurred when attempting to evaluate this template:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mholtum/public_html/test/includes/adminfunctions_template.php(3515) : eval()'d code on line 181
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
He missed an </if> at the end of his code. Add it in, and it should work. ;)
Not sure why, but all I'm getting for this is the following. My other admin says its working fine for him though.
dsboyce8624
06-16-2005, 05:05 PM
Is there something like this for 3.0.x? Don't seem to find anything on searching.
mholtum
06-16-2005, 05:07 PM
He missed an </if> at the end of his code. Add it in, and it should work. ;)I figured that, does it matter where I put it?
fraghappy
06-16-2005, 08:41 PM
Not sure why, but all I'm getting for this is the following. My other admin says its working fine for him though.
Hmm... could it perhaps be a browser issue? Do you use Firefox or Internet Explorer? Once I track down the problem, I release v1.2. After that, though, I probably won't work on this plugin much more, as I'm going to make it one of the features in a more advanced plugin that I'm developing.
Is there something like this for 3.0.x? Don't seem to find anything on searching.
Nope. As far as I know, it is an original idea.
I figured that, does it matter where I put it?
Just put it at the end of the template code that he posted. ;)
Kirk Y
06-17-2005, 04:59 AM
He missed an </if> at the end of his code. Add it in, and it should work. ;)
Strange, I have just that one </if>, my template gave no code errors. Hmm...
Is there something like this for 3.0.x? Don't seem to find anything on searching.
Yes, actually there is a hack that was just recently released based off of this plugin.
Use the directions, here: https://vborg.vbsupport.ru/showthread.php?p=668118
But be sure to take a look at this post, to see how to make it work for 3.0.x.:
https://vborg.vbsupport.ru/showpost.php?p=667824&postcount=9
Hope everything works out for you. :classic:
Dark Riku
06-18-2005, 07:24 AM
Yea..So i need some Serious Help lol
http://www.gfxwiz.net/wtf.JPG
works on the navbar..but not near the poster, and now i cant even delete it? lol
(Happening on all my skins, except Default, I Even tryed to reinstall the skins, same thing)
Lostitonce
06-24-2005, 03:12 PM
I am having a problem with this plugin - it never showed avatar to begin with , just a red x . Now it has been removed , but , is still showing a red x in my navbar ?
fraghappy
06-24-2005, 03:49 PM
Yea..So i need some Serious Help lol
works on the navbar..but not near the poster, and now i cant even delete it? lol
(Happening on all my skins, except Default, I Even tryed to reinstall the skins, same thing)
That shouldn't have anything to do with this hack, as it doesn't change any of the 'showthread' variables.
I am having a problem with this plugin - it never showed avatar to begin with , just a red x . Now it has been removed , but , is still showing a red x in my navbar ?
You have to undo the template modifications, because it's still searching for the picture in the navbar. I'm expanding this plugin into a "Navbar Plus" plugin, so I'll try to fix some of these issues then. It would help if I had a bit more information about your forum to understand why it is giving you the red X, as it has worked on 95% of the forums that have installed it. ;)
dsboyce8624
06-25-2005, 02:45 AM
Nope. As far as I know, it is an original idea.
I created one. I like the idea.
Lostitonce
06-25-2005, 05:53 PM
You have to undo the template modifications, because it's still searching for the picture in the navbar. I'm expanding this plugin into a "Navbar Plus" plugin, so I'll try to fix some of these issues then. It would help if I had a bit more information about your forum to understand why it is giving you the red X, as it has worked on 95% of the forums that have installed it. ;)
I did undo the template modifications , deleted the plugin , and it is still trying to show up , lol .
What kind of info do you need ? My forum is here : http://www.dogeplanet.com/forum/index.php?
jesse
06-28-2005, 05:53 AM
Not sure why, but all I'm getting for this is the following. My other admin says its working fine for him though.
I have this problem with ie but not the fox
o0Hubba0o
10-03-2005, 03:39 PM
Yea..So i need some Serious Help lol
Riku, the help you need can't be found on these forums! :p
Mastar
10-22-2005, 05:23 PM
I am having this same problem as Jaxx.
hitmanuk2k
01-13-2006, 10:44 AM
OK I can't display an image, all that comes up is "Your Avatar" - which is the image alt.
t3aseFP
02-02-2006, 05:26 PM
Cool plugin, works nice.
One question, when using vBadvanced, the homepage uses navbar, but the avatar will not show. I'm assuming because there's a variable that's not set when using the vBa based page.
Throughout the vB pages it works fine, though.
Any way you can let me know how to define the variable for vBa or hack it to work? I'll start playing with things in the mean time.
Gripemaster
02-03-2006, 12:41 PM
I'm afraid I had to uninstall this one :(
I'm rather liberal with my avatar sizes (150 X 150 and 150KB), and it left a HUGE blank space between my two navbars that just didn't look right. Is there a way of making the script resize the avatar to a smaller size? I would still like to use this product :)
t3aseFP
02-04-2006, 01:54 AM
I'm afraid I had to uninstall this one :(
I'm rather liberal with my avatar sizes (150 X 150 and 150KB), and it left a HUGE blank space between my two navbars that just didn't look right. Is there a way of making the script resize the avatar to a smaller size? I would still like to use this product :)
<td style="vertical-align: bottom; width: 80px; height: 60px; margin: 0px; padding: 0px;">
<a href="profile.php?$session[sessionurl]do=editavatar"><img src="$navbar_ava[0]" alt="Your avatar" style="width: 100%; height: 100%;" border="0"/></a>
Just add the td and img style attributes and edit as desired.
Gripemaster
02-04-2006, 03:17 AM
<td style="vertical-align: bottom; width: 80px; height: 60px; margin: 0px; padding: 0px;">
<a href="profile.php?$session[sessionurl]do=editavatar"><img src="$navbar_ava[0]" alt="Your avatar" style="width: 100%; height: 100%;" border="0"/></a>
Just add the td and img style attributes and edit as desired.
Excellent!!! Thank you! :)
mploetner
03-07-2006, 05:04 PM
OK I can't display an image, all that comes up is "Your Avatar" - which is the image alt.
same to me... any suggestions
gravesend46
04-24-2006, 08:39 PM
Thanks, seems to work for me on 3.5.4!
Cool plugin, works nice.
One question, when using vBadvanced, the homepage uses navbar, but the avatar will not show. I'm assuming because there's a variable that's not set when using the vBa based page.
Throughout the vB pages it works fine, though.
Any way you can let me know how to define the variable for vBa or hack it to work? I'll start playing with things in the mean time.
I'm in the same boat - would love to get this working on VBA as well.
Annapurna
05-25-2006, 03:20 PM
Nice hack, installed, but then realized, that is does not work with Firefox (see screenshot)
48215
Andreas
is there an easy way to make this the profile picture instead
carmichael1973
06-08-2008, 12:22 PM
I'm in the same boat - would love to get this working on VBA as well.
I'm stuck with the same issue. I can't get the avatar to show on non-vb pages. Everything else works fine. This is an awesome hack. I've played around with these variables and I get DB errors if I change the fetch_avatar_url.
if ($vbulletin->userinfo['userid'])
{
require_once('./includes/functions_user.php'); //make sure we have the function we need
$navbar_ava = fetch_avatar_url($vbulletin->userinfo['userid']);
if (!is_array($navbar_ava))
{
$navbar_ava[] = $vbulletin->options['bburl'] . "/images/misc/noavatar.gif";
}
}
If anyone figures this out, PLEASE post it!
:up:
edgeyveggie
06-13-2008, 12:50 AM
How can I do this with 3.6.8? I'd love to know!!
carmichael1973
07-27-2008, 05:11 PM
I just posted a simple version of this HERE (https://vborg.vbsupport.ru/showthread.php?t=186493). I'm not a hardcore developer like fraghappy, but it works just fine.
I really liked this mod and when I lost all of my Avatars on Non-VB pages when I went to 3.7.0 I had to do something!
Bonee70
08-09-2008, 11:41 PM
How can I do this with 3.6.8? I'd love to know!!
Me too, I can't get it to work on 3.6.8 ....
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.