Advertisement:

Author Topic: Customize 'Who's Online'  (Read 11402 times)

Offline jrstark

  • Jr. Member
  • **
  • Posts: 144
Re: Customize 'Who's Online'
« Reply #20 on: April 29, 2011, 03:23:58 PM »
Very cool, thanks!

Offline Owdy

  • SMF Fossil
  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,627
  • Gender: Male
  • W00t!
    • janoloferiksson on LinkedIn
    • @@jaoler on Twitter
Re: Customize 'Who's Online'
« Reply #21 on: April 29, 2011, 04:03:29 PM »
If you are using SMF 2, remember empty SMF cache after lang file edit (if you dont edit it via admin panel) :)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Offline HunterP

  • Sr. Member
  • ****
  • Posts: 976
  • Gender: Male
  • SMF 2.0.4
    • Hulpverleningsforum Nederland
Re: Customize 'Who's Online'
« Reply #22 on: October 16, 2011, 01:23:15 PM »
Code: (find in Sources/Who.php) [Select]
$context['show_methods'] = array(
'all' => $txt['who_show_all'],
'members' => $txt['who_show_members_only'],
'guests' => $txt['who_show_guests_only'],
);

By default, "guests" is selected. How can i make "Members" the default selection?

Took a while (ofcourse I haven't bee looking for this all the time), but I found it :

File : Who.php
Function: Who()

Code: [Select]
// Fallback to top filter?
if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
$_REQUEST['show'] = $_REQUEST['show_top'];
// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
{
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
}
// Perhaps we saved a filter earlier in the session?
elseif (isset($_SESSION['who_online_filter']))
{
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
}
else
$context['show_by'] = $_SESSION['who_online_filter'] = 'all';

Change the last line into :

Code: [Select]
$context['show_by'] = $_SESSION['who_online_filter'] = 'members';
And "members" will be the default selection.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,157
  • Gender: Male
    • i30 Owners Club
Re: Customize 'Who's Online'
« Reply #23 on: October 16, 2011, 01:36:48 PM »

Change the last line into :

Code: [Select]
$context['show_by'] = $_SESSION['who_online_filter'] = 'members';
And "members" will be the default selection.

Thank you. I've been hunting that down for a week now  ;D

Offline HunterP

  • Sr. Member
  • ****
  • Posts: 976
  • Gender: Male
  • SMF 2.0.4
    • Hulpverleningsforum Nederland
Re: Customize 'Who's Online'
« Reply #24 on: November 19, 2011, 04:14:23 PM »

A little update. Sometimes when the dropdownbox shows "members", all visitors (members and guests) are being displayed. When selecting all (or guests) and reselecting "Members" again, it's OK. I figured out that one line needs to be added :

Code: [Select]
// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
{
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
}
// Perhaps we saved a filter earlier in the session?
elseif (isset($_SESSION['who_online_filter']))
{
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
}
else
{
$context['show_by'] = $_SESSION['who_online_filter'] = 'members'; // was 'all'
$conditions[] = $show_methods[$_REQUEST['show']];
}

When I added the last line :

      $conditions[] = $show_methods[$_REQUEST['show']];

It finally seems to work OK.