Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Tag for "This user is online"

Quote Reply
Tag for "This user is online"
Hi,

Is there a tag that we can use to show in include_post_display.html template if the sender of the message is online: <%if message_sender is online%>This user is online!<%endif%>?

Thank you! Smile

François
Post deleted by Jagerman In reply to
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
Hi Jason,

Thank you very much for your fast answer!

I tried the global, but there is a little problem: users that are not online are showed as online - in others words, all users are showed as online.

Thank you for your help!

François

Last edited by:

Franco: Aug 13, 2002, 9:11 PM
Post deleted by Jagerman In reply to

Last edited by:

Jagerman: Aug 13, 2002, 9:27 PM
Post deleted by ellipsiiis In reply to
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
It still doesn't work. The problem seems to be that you can't have if statements on subroutine globals. The code of your first example works fine when you just do it as a simple variable, but it will always return true for an if statement. The second code doesn't work at all for me.


Realiiity.com Forums
Quote Reply
Re: [ellipsiiis] Tag for "This user is online" In reply to
Okay, here goes try number 3 (this time, it definitely works):

Code:


sub {
my $tags = GT::Template->tags;
my $user_id = $tags->{user_id_fk} or return;
my $c = $DB->table('Online')->count(GT::SQL::Condition->new(
user_id_fk => '=' => $user_id,
online_invisible => '=' => 0,
online_time => '>=' => (time - $CFG->{online_timeout} * 60)
));
return { user_online => $c };
}


In the template, you need to put:

<%check_user_online()%>

then:

<%if user_online%>Online!<%else%>Offline<%endif%>



*Sigh* - I'll add this to the bug list, it shouldn't be so convoluted - the other examples should work (but obviously don't). Frown

Unfortunately, I'm the main template parser maintainer so I can't get someone else to fix it Blush.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
Hi Jason,

The try number 3 still doesn't work on my side. I get the error:

"Error: Variable 'check_user_online' is not a code reference"

Thank you.

François
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Hello Franco


You must call the sub check_user_online in your Admin Planel them the sub works.

greeting hoefti
linktobuy Web Directory
Ratgeber Recht
Quote Reply
Re: [hoefti] Tag for "This user is online" In reply to
Thank you! But how I do that??

François
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Hello franco

go to your Admin Planel

Websiteadress/ cgi-bin/gforum/admin/admin.cgi

Link Templates then the last Link by templates in germen call "Globale Variablen" in english global variable ?

Ok then you go to the end of this site an put check_user_online in the left field an in the right field
Code:
sub { my $tags = GT::Template->tags; my $user_id = $tags->{user_id_fk} or return; my $c = $DB->table('Online')->count(GT::SQL::Condition->new( user_id_fk => '=' => $user_id, online_invisible => '=' => 0, online_time => '>=' => (time - $CFG->{online_timeout} * 60) )); return { user_online => $c }; }

Now you have a new global Variable

in the template include post display.html

after
Code:
<%else%>
<big><%nbsp post_username%></big>
<%endif%>

add
Code:
<%if user_invisible%> <i> invisible </i>
<%else%><%check_user_online()%> <%if user_online%> [Online] <%else%>[Offline]<%endif%><%endif%>

if the User dosent want to show if he ist online the output is invisible oder leave blank for nothing


i hope you can understand me

greetings hoefti
linktobuy Web Directory
Ratgeber Recht
Quote Reply
Re: [hoefti] Tag for "This user is online" In reply to
Hi hoefti,

You simply meant: rename the global "user_online" to "check_user_online"! Now I understand! Laugh

Thanks to you and Jason! It works perfectly now!

François Smile
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
Hi Jason,

Your solution works great in include_post_display.html but not in user_view.html - nothing is printed in user_view.html. Do you know why and how to solve this?

Thank you very very much! Smile

François
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Hi François,

You're going to have to change the global slightly to get $tags->{user_id} instead of $tags->{user_id_fk} - I'd create a new global, so you'll have two - check_user_id_fk_online and check_user_id_online, both would set a user_online tag.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
Thank you, Jason, it works now in user_view.html. But I noticed that even if the user click on "log out", he still showed "Online" during all the "online_timeout". Is there a way that the global can check if the user closed his session (logged out) by himself?

Thank you very much!

François
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Hi François,

No, it won't work like that. When you log out, no record is made of it in Gossamer Forum for a variety of reasons (for example, there could be two people logged in with different sessions), and so whether or not a user is online is determined by whether or not they show up on the Who's Online page. It might be a little confusing to see someone on the Who's Online page, but beside their post it does not show them as online.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
«...It might be a little confusing to see someone on the Who's Online page, but beside their post it does not show them as online.»

I don't think so on my side, since it's written on the "Who's Online" page: "x registered users have accessed the forum in the last 15 minutes:"

Instead to use the "online_timeout" session, how can I use in the global another timeout session setting (exemple: 7 minutes). Maybe a global that simply check the difference between the variable "user_last_seen" and "current_time(?)" will simply do the job. Exemple: if the difference between "user_last_seen" is more than 7 minutes, then the user will be showed as offline.

Thank you!

François
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Just take out the part that says "$CFG->{online_timeout}" and replace it with the number of minutes - in this case, 7.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Tag for "This user is online" In reply to
Thank you very much!!

François Smile
Quote Reply
Re: [Franco] Tag for "This user is online" In reply to
Is this going to be added in 1.1.8?Angelic

openoffice + gimp + sketch ... Smile