The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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']; } } Code:
var_dump($steam_info['avatarfull']); Quote:
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> |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
<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)" /> Code:
<vb:elseif condition="$post[usergroupid] == 13"> 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)" /> 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}}" /> Code:
<vb:elseif condition="empty($steam_info)"/> 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> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|