[SOLVED] user list, online only or, online and then last online

7 years 7 months ago - 7 years 7 months ago #285634 by smFruen
this code works fine, and show everyone who is online.
but it also shows those who are not online in order of oldest first

( ( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) IS NULL )


Can i make a code which only show those online.

Or

one showing them that are online first, and then afterwards those who were last online

Attachments:

Please Log in to join the conversation.

7 years 7 months ago #285636 by krileon
You added an advanced sort, not an advanced filter. This means it's adding your custom query to the Order By of the userlist query and not the WHERE. If you want online users ordered first then the below should work fine.

( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) DESC

The below can be used to filter the userlist to online users only.

( SELECT COUNT(*) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) > 0


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 7 months ago #285639 by smFruen
Works fine now which only show online

thanks.

can i also make one, where I filters, online first and then show those who were online last ?

Please Log in to join the conversation.

7 years 7 months ago #285640 by smFruen
want online users ordered first then lastvisitdate descending , in one list

Please Log in to join the conversation.

7 years 7 months ago #285686 by krileon
Then you need to do that in an advanced order by, which combines the order by I've already provided you with an addition of lastvisitdate. Below will probably work.

( SELECT MAX( s.`time` ) FROM `#__session` AS s WHERE s.`userid` = u.`id` AND s.`guest` = 0 ) DESC, u.`lastvisitdate` DESC


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 7 months ago #285698 by smFruen
smiles, thanks it works fine.


thanks

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.211 seconds

Facebook Twitter LinkedIn