Log in

View Full Version : Need help with useronline status, need just the number...


Kalina
02-07-2008, 01:42 PM
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: https://vborg.vbsupport.ru/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?

Lynne
02-07-2008, 01:56 PM
What is the code you are currently using that isn't working? And have you tried printing out the variable it is getting so you can see what is going wrong?

Kalina
02-07-2008, 01:59 PM
I had it working a few days ago but changed something and it stopped working and I don't have the code I had used, all I have is the plugin code I linked to above, I don't know where to go from there or how to print anything out.

Opserty
02-07-2008, 03:00 PM
Look at the (default vBulletin skin) postbit template and see how they change the image depending on the users status. Then just use those conditions to set up what you want. vBulletin fetches the online status by default in the postbit, so there is no need to fetch it yourself with a plugin.

Kalina
02-07-2008, 10:37 PM
Look at the (default vBulletin skin) postbit template and see how they change the image depending on the users status. Then just use those conditions to set up what you want. vBulletin fetches the online status by default in the postbit, so there is no need to fetch it yourself with a plugin.

I know, but it does not work, it's returning an image, I need to return a variable.

--------------- Added 1202434932 at 1202434932 ---------------

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

--------------- Added 1202445242 at 1202445242 ---------------

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?

Lynne
02-08-2008, 02:36 AM
Have you tried not caching the template and then flushing your cache and seeing if it works?

Kalina
02-08-2008, 08:37 AM
I figured it out on my own, no plugins, just conditionals. Thanks. :)