Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-03-2012, 05:09 PM
shibby2 shibby2 is offline
 
Join Date: Jul 2005
Posts: 303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need code for this.. please help..

Hi everyone, I'm using the following code to make the user's avatar appear..

Code:
<img src="$vboptions[bbdir]/forums/image.php?u=$bbuserinfo[userid]" alt="Your avatar" border="0" />

This works fine IF they have an avatar. If they don't it shows up as a broken image (red X).

My question is, what code would I have to add to make a "No Avatar" image show up for people who don't have an avatar? I already have the No Avatar image uploaded to the forum directory.

Any help would be HUGE!

Thanks!
Reply With Quote
  #2  
Old 10-03-2012, 08:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The situation is a little complicated. A user can have a "standard" avatar, a custom avatar, or no avatar. image.php only returns the custom avatar, so you really shouldn't be calling that unless you already know that the user has one (otherwise you get a broken image). Also, assuming a user does have a custom avatar, you should be putting a timestamp on the url (like image.php?userid=X&dateline=Y) otherwise a browser will cache it and maybe not see a change in a user's custom avatar for days after it happens.

So anyway, you should be checking what kind of avatar a user has and building the url accordingly, instead of always using image.php. What template is your code from?
Reply With Quote
  #3  
Old 10-03-2012, 08:45 PM
shibby2 shibby2 is offline
 
Join Date: Jul 2005
Posts: 303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, ok, thanks for the insight. Unfortunately I dont know much about what youre saying (im dumb). lmao I just found that code somewhere in a post last night while searching vb.org.

The thing is, I'm using the Vietbb side column mod. As you may know, it doesn't work properly when you code it into forum_display (it works on index fine, but if you dont want it on evry page, you ahve to manually add it to whatever pages you want. Since I dont want it on showthread, I had to add it to forum_display only). The User Information box will show up, but the avatar doesnt. Soooo I got it to show with that code above, but not when someone doesnt have an avatar.

Is there a basic piece of code I could use instead of that? Im really not good with this stuff at all. lol

Thanks for the help so far!
Reply With Quote
  #4  
Old 10-03-2012, 11:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, this really should be done in a plugin, but it is possible to do in a template. Here's what I came up with:
Code:
<if condition="$bbuserinfo[avatarid]"><img src="$bbuserinfo[avatarpath]" alt="Your avatar" border="0" /><else /><if condition="$bbuserinfo['hascustomavatar'] AND $vboptions['avatarenabled']"><if condition="$vboptions['usefileavatar']"><img src="{$bbuserinfo[avatarurl]}/avatar{$bbuserinfo[userid]}_{$bbuserinfo[avatarrevision]}.gif"<else /><img src="image.php?{$session[sessionurl_q]}u={$bbuserinfo[userid]}&amp;dateline={$bbuserinfo[avatardateline]}"</if><if condition="$bbuserinfo['avwidth'] AND $bbuserinfo['avheight']"> width="{$bbuserinfo[avwidth]}" height="{$bbuserinfo[avheight]}"</if> alt="Your avatar" border="0" /></if></if>

I put it all on one line so that there wouldn't be any extra spaces in the output, which is why it looks so scary.

One other thing: this only works if the current user's info contains the avatar info, and on a lot of pages (like forumhome) it won't. But it turns out you can fix that by adding this to your config.php file (anywhere after the first line):
Code:
define('AVATAR_ON_NAVBAR', 1);

There doesn't seem to be anything that actually puts the avatar on the navbar, so I guess it's something that's left over from an older version (or maybe never got implemented).
Reply With Quote
  #5  
Old 10-03-2012, 11:17 PM
shibby2 shibby2 is offline
 
Join Date: Jul 2005
Posts: 303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ut oh, that didn't work, and now certain forums on my forum wont work. Also, the images in my photo album dont work.

This is the message I get in certain forums even after removing the code from config.php:

Unable to add cookies, header already sent.
File: /home/screamin/public_html/myforum.com/includes/config.php
Line: 1
Reply With Quote
  #6  
Old 10-03-2012, 11:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, well, you can take it out to fix things right?

Where exactly did you put it?
Reply With Quote
  #7  
Old 10-03-2012, 11:21 PM
shibby2 shibby2 is offline
 
Join Date: Jul 2005
Posts: 303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I took it back out right away, and Im still getting the same message in certain forums. I put it after the first line in config.php.

--------------- Added [DATE]1349310398[/DATE] at [TIME]1349310398[/TIME] ---------------

Any forums with new posts (unread) will work, any forums that are 'read' will be blank with only that message displayed.

Album images and avatars are a red X.

Reply With Quote
  #8  
Old 10-03-2012, 11:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you put all that code in the config.php? Sorry, only that one line I posted in the second part was supposed to go in there.

If you only changed your config.php, and you took it out but are still having problems, then you must not have gotten it back the way it was. WHat did you use to edit it?
Reply With Quote
  #9  
Old 10-03-2012, 11:39 PM
shibby2 shibby2 is offline
 
Join Date: Jul 2005
Posts: 303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea, I only put in that one piece from the second part.

I used Notepad.

It looked like there was line breaks after every line in onfig, so I even uploaded a new, fresh cope without line breaks, and Im still getting the same problem.

Ugh, this sucks, I have a fairly active forum too..

Reply With Quote
  #10  
Old 10-03-2012, 11:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're still getting that same error even after uploading a new copy? Are you sure you uploaded it to the right place (it should be in inlcudes). Also, it has your database and other config stuff in there so you don't want to upload the copy that came with vbulletin (hopefully you knew that, but just to make sure...).

That error definitely looks like what you get when there's something at the beginning of the config.php file other than <?php
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:50 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04493 seconds
  • Memory Usage 2,256KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete