Colleen78 Posted February 8, 2008 Share Posted February 8, 2008 I am trying to make it so a background image in my postbit changes color depending on if a user is online, offline or invisible. I am doing this by assigning a class which I need to change using conditionals, and I found this bit of code for a plugin: http://www.vbulletin.org/forum/showpost.php?p=1323306&postcount=8 However, it's not working, it's showing everyone as offline. What's the best way to go about doing this? I had my class change depending on the users status, ie "class="online1"... The "1" would be the part that changes to either 0, 1 or 2... any ideas how to get this working? Here's what I have so far. I made a custom template. Title: postbit_onlinestatus_two Inside that template: <if condition="$onlinestatus==0">0</if><if condition="$onlinestatus==1">1</if><if condition="$onlinestatus==2">2</if> I've made a plugin to cache the template. Hook Location: cache_templates Title: cache custom templates Code: $globaltemplates = array_merge($globaltemplates, array('beer','drink','postbit_onlinestatus_two')); (it's caching other templates as well) I've created a plugin to execute the template. Hook Location: postbit_display_complete Title: Postbit Online Status Code: eval('$postbitonlinestatus = "' . fetch_template('postbit_onlinestatus_two') . '";'); And the code in my postbit template: <div class="online$postbitonlinestatus"> It's currently returning a "0" regardless if I am online or not. Can someone please give me a little guidance to get this working? Thank you. Link to comment https://forums.phpfreaks.com/topic/89996-need-to-return-a-variable-for-useronline-status-in-vbulletin/ Share on other sites More sharing options...
Colleen78 Posted February 8, 2008 Author Share Posted February 8, 2008 By default, vbulletin returns an image to indicate if a user is online, offline, or invisible, I am trying to return text, I could just do that in the default template, but can't because I am using the default template as it is in other areas, such as the members profile page. This is hard code in one of the files to return a users online status. $onlinestatus = 0; // now decide if we can see the user or not if ($user['lastactivity'] > $datecut AND $user['lastvisit'] != $user['lastactivity']) { if ($user['invisible']) { if (($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) OR $user['userid'] == $vbulletin->userinfo['userid']) { // user is online and invisible BUT bbuser can see them $user['invisiblemark'] = '*'; $onlinestatus = 2; } } else { // user is online and visible $onlinestatus = 1; } } if ($setstatusimage) { eval('$user[\'onlinestatus\'] = "' . fetch_template('postbit_onlinestatus') . '";'); } return $onlinestatus; } I hope that helps, I've been trying to figure this out for 2 days. Link to comment https://forums.phpfreaks.com/topic/89996-need-to-return-a-variable-for-useronline-status-in-vbulletin/#findComment-461448 Share on other sites More sharing options...
Colleen78 Posted February 8, 2008 Author Share Posted February 8, 2008 I came up with a solution but have one last issue, it's not parsing correctly when using quick reply, it loads in using the image code instead, but on refresh it's fine. I don't have to use plugins or anything, I just did this to my postbit_onlinestatus template: <if condition="$vbulletin->userinfo['field8'] != 'Horizontal Postbit' AND in_array(THIS_SCRIPT, array('showthread','private'))"><if condition="$onlinestatus==0">0</if><if condition="$onlinestatus==1">1</if><if condition="$onlinestatus==2">2</if><else /><if condition="$onlinestatus==0"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_offline.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_offline]</phrase>" border="0" /></if> <if condition="$onlinestatus==1"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_online.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_online_now]</phrase>" border="0" /></if> <if condition="$onlinestatus==2"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_invisible.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_invisible]</phrase>" border="0" /></if></if> My members can choose their postbit, hence the first part of the code. Any ideas how to make this parse right away with quick reply? Link to comment https://forums.phpfreaks.com/topic/89996-need-to-return-a-variable-for-useronline-status-in-vbulletin/#findComment-461511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.