vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Way to check for Avatar on FORUMHOME and Postbit? (https://vborg.vbsupport.ru/showthread.php?t=290296)

RedTurtle 11-07-2012 03:32 PM

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

kh99 11-09-2012 02:33 PM

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>


RedTurtle 11-09-2012 03:51 PM

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!

kh99 11-09-2012 03:59 PM

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?

RedTurtle 11-09-2012 04:03 PM

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.

kh99 11-09-2012 04:10 PM

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>


RedTurtle 11-09-2012 04:15 PM

Thank you again kh99! :)

That did it! :D


All times are GMT. The time now is 06:54 AM.

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.01760 seconds
  • Memory Usage 1,737KB
  • 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
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete