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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2016, 08:42 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Template variable refusing to work

Oke, so.. I am using the steam plugin, with the following targeting postbit_display_start:

Code:
global $vbulletin; 

include_once(DIR . '/includes/functions_steamconnect.php'); 

if (THIS_SCRIPT == 'private') { 
    global $pm; 
    $stc_user_info = fetch_userinfo($pm['fromuserid']); 
    $steam_info = fetch_steam_info(get_user_steamid($stc_user_info), $vbulletin->options['stc_apikey']); 
     
    if (!empty($steam_info)) { 
        $this->post['steamavatarfull'] = $steam_info['avatarfull']; 
        $this->post['steamavatar'] = $steam_info['avatar']; 
        $this->post['steamavatarmedium'] = $steam_info['avatarmedium']; 
    } 
} else { 
    $stc_user_info = fetch_userinfo($post['userid']); 
    $steam_info = fetch_steam_info(get_user_steamid($stc_user_info), $vbulletin->options['stc_apikey']); 

    if (!empty($steam_info)) { 
        $this->post['steamavatarfull'] = $steam_info['avatarfull']; 
        $this->post['steamavatar'] = $steam_info['avatar']; 
        $this->post['steamavatarmedium'] = $steam_info['avatarmedium']; 
    } 
}
At the end, I added:

Code:
var_dump($steam_info['avatarfull']);
Results in a thread were:
Quote:
string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/7e/7e35511d79a0734bc975ddefbf84f76fe05a8800_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/64/64a693386d3647d74f48f6da659e19ffdefc9f71_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/e2/e22f276e1de68aeaff357d1a40792e1aaefa350c_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/e9/e9d4b42fd3734cb71fb2475019d6e8fafb5a78a4_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/a8/a8387bdd76aa295bb3056c9f902ab5c07ecac138_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/ea/eaf8dd354ce9418ec1da2488715110158f395209_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/ea/eaf8dd354ce9418ec1da2488715110158f395209_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/e0/e00ec9e849be38667112ecd5f0d524077e08dd48_medium.jp g" string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/1c/1c5e36c2e186e3b726748a9c17dbf57cea502663_medium.jp g"
Yay, it works! It shows all the steam images of the users who have posted in the thread. Now.. for some reason, when I use the following template code in postbit_legacy:

Code:
<vb:if condition="$show['avatar']">
                    <a class="postuseravatar" href="{vb:link member, {vb:raw post}}">
                        <vb:if condition="$post.avatarurl">
                            <img src="/{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
                        
                        </vb:if>
                    </a>
							<vb:elseif condition="is_member_of($bbuserinfo, 13)" />
							<img class="postuseravatar" src="{vb:raw steam_info.avatarfull}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
                      
							<vb:else />	
							<img class="postuseravatar" src="/{vb:stylevar imgdir_misc}/avatar.png" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
                </vb:if>
The avatar url is not being implemented.. While the var_dump worked just fine. (see bold code above that I added) I cannot figure out why. I've been trying to figure out for quite some time why it doesn't work, already tried adding a src with the img target being {vb:raw steam_info.avatarfull} outside the avatar area.. still not working. Any idea anyone?
Reply With Quote
  #2  
Old 02-19-2016, 10:48 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If $show['avatar'] contains something, it will always go into the first if statement first and ignore the rest. So you'll have to unset that variable for it to make it to the elseif.

Edit: it doesn't work because you use the wrong variable in the template.
post.steamavatarfull, post.steamavatar and post.steamavatarmedium is what you should use. The other variable is never assigned to the post array.
Reply With Quote
  #3  
Old 02-19-2016, 11:29 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<3, thank you! Wish I could like your post, but it says I have to like someone else first . It works perfectly now, I'll remember the variable the next time, really appreciate it.

EDIT:
How can I make it so it'll affact guest views as well? For members (most likely because I'm in usergroup 13) it works just fine. However, people outside the usergroup 13 (in this case, guests) still shows a default vB avatar. I assumed that:


Code:
<vb:elseif condition="is_member_of($bbuserinfo, 13)" />
or
Code:
<vb:elseif condition="$post[usergroupid] == 13">
Would have worked, because the user of the post is in usergroup 13. Guess it doesn't. The idea is to only show the steam avatar for everyone if the user is part of usergroup 13; if the user has vBulletin uploaded avatar to show for everyone.

Double edit..
Now I tried a different approach, seeing some users do have information in their steam table, but are not part of usergroup 13.
Code:
<vb:elseif condition="!empty($steam_info)" />
But so far, doesn't work.

Code:
<vb:elseif condition="!empty($steam_info)" />
<img class="postuseravatar" src="{vb:raw steam_info.avatarfull}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
BUT:
Code:
<vb:elseif condition="empty($steam_info)"/>
Works? Its showing the steam avatars now.. I'm confused, ! should be the opposite of empty.. Seeing if the steam table is empty, no avatar can be grabbed.

To keep you guys up-to-date, the system I had in mind is as follows:

1), Use vBulletin avatar (custom, that the user uploaded) as priority
2), If user has no custom avatar, fall back to users steam avatar IF the user has steam linked (hence: !empty($steam_info)
3), If user has no custom avatar nor has his/her profile steam linked, use /{vb:stylevar imgdir_misc}/avatar.png instead.

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

Sorry for the duplicate post (if this post isn't being merged)... But, I got the solution which is working perfectly.

Code:
<vb:if condition="$show['avatar']">
<a class="postuseravatar" href="{vb:link member, {vb:raw post}}">
<vb:if condition="$post.avatarurl">
<img src="/{vb:raw post.avatarurl}" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
</vb:if>
</a>
<vb:elseif condition="$post[steamavatarfull] == !NULL"/>
<img class="postuseravatar" src="{vb:raw post.steamavatarfull}" width="120" height="120" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
                      
<vb:elseif condition="$post[steamavatarfull] == NULL"/>
<img class="postuseravatar" src="/{vb:stylevar imgdir_misc}/avatar.png" alt="{vb:rawphrase xs_avatar, {vb:raw post.username}}" />
                </vb:if>
While it works just fine. I'm curious if this is the best way to do it. See the bold text above of what I added.
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 04:54 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.04650 seconds
  • Memory Usage 2,189KB
  • 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
  • (9)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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