Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 11-07-2012, 03:32 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Way to check for Avatar on FORUMHOME and Postbit?

Hi guys,

I would like to encourage my users who do not have an avatar set to upload one for themselves. To this end I am looking to see if there is a conditional I can use either on FORUMHOME (maybe via notices manager?) and also in the postbit template that would check if they have an avatar set.

On the postbit I was thinking on their posts, it would show a link in their profile info area telling them to click on a link to set an avatar if they do not already have one, and on FORUMHOME it could show a notice or something asking them to get an avatar.

Is this possible? Thank you!
Reply With Quote
  #2  
Old 11-09-2012, 02:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the posts you could check $post[postid] == 0 and !$post[hascustomavatar], so you could maybe do this:

Code:
<vb:if condtiion="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
// Post belongs to logged in user and that user doesn't have an avatar
<vb:else />
// Existing avatar code
</vb:if>

I'm not sure if the same check will work on FORUMHOME because I'm not sure if you have the avatar info by default. If it does work, then it would be something like:

Code:
<vb:if condtiion="$bbuserinfo[avatarid] == 0 AND !$bbuserinfo[hascustomavatar]">
// Logged in user has no avatar
</vb:if>
Reply With Quote
  #3  
Old 11-09-2012, 03:51 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you kh99!

I'm not so concerned about forumhome I suppose. But getting it to work on postbit would be really nice.

Unfortunately I'm having an issue with it working. This is the code I am using:

Code:
<vb:if condition="$show['avatar']">
			<vb:if condition="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
			<vb:comment>Post belongs to logged in user and that user doesn't have an avatar</vb:comment>
			<a class="postuseravatar" href="/profile.php?do=editavatar" title="Click here to choose your picture!">
				<img src="/images/misc/unknown.gif" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="Click here to choose your picture!" />
			</a>
			<vb:else />
			<vb:comment>Existing avatar code</vb:comment>
			<a class="postuseravatar" href="{vb:link member, {vb:raw post}}" title="{vb:rawphrase {vb:raw post['onlinestatusphrase']}, {vb:raw post.username}}">
				<img src="{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
			</a>
			</vb:if>
			</vb:if>
but the issue I have is that the image I am trying to get to show up for when a user doesn't have an avatar, isn't showing up. I want that image to be what they click on to take them to the Edit Avatar page but for some reason it isn't showing.

Any idea what I'm doing wrong? Thanks!
Reply With Quote
  #4  
Old 11-09-2012, 03:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have this:
Code:
<img src="/images/misc/unknown.gif" ...

Are you sure that's the right path to the image? Maybe try taking off the beginning '/' and see if that works. Otherwise, did you check the page html to see if it's what you'd expect?
Reply With Quote
  #5  
Old 11-09-2012, 04:03 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the response.

I did double check the path, tried removing the leading '/' and even tried an absolute path but it didn't work. Also checking the source html (great idea btw ) also doesn't show that portion of code at all which makes me think the conditional isn't working properly?

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

Update:

If I install this product here: https://vborg.vbsupport.ru/showthread.php?t=227947 then your code works properly but the downside is that it shows a default avatar for every single person who doesn't have one, whereas I want it to only show that avatar to the person logged in, asking them to set a custom avatar.
Reply With Quote
  #6  
Old 11-09-2012, 04:10 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, yeah, the problem seems to be that $show['avatar'] is false if the user has no avatar, but it can also be false if the logged in user has chosen not to see avatars. So maybe this:

Code:
<vb:if condition="$bbuserinfo[userid] <= 0 OR $bbuserinfo[showavatars]">
			<vb:if condition="$post[userid] == $bbuserinfo[userid] AND $post[avatarid] == 0 AND !$post[hascustomavatar]">
			<vb:comment>Post belongs to logged in user and that user doesn't have an avatar</vb:comment>
			<a class="postuseravatar" href="/profile.php?do=editavatar" title="Click here to choose your picture!">
				<img src="/images/misc/unknown.gif" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="Click here to choose your picture!" />
			</a>
			<vb:else />
                        <vb:if condition="$show[avatar]">
			<vb:comment>Existing avatar code</vb:comment>
			<a class="postuseravatar" href="{vb:link member, {vb:raw post}}" title="{vb:rawphrase {vb:raw post['onlinestatusphrase']}, {vb:raw post.username}}">
				<img src="{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" title="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
			</a>
			</vb:if>
			</vb:if>
<vb:if>
Reply With Quote
  #7  
Old 11-09-2012, 04:15 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you again kh99!

That did it!
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:21 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.04275 seconds
  • Memory Usage 2,219KB
  • 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
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete