Customize 'Who's Online'

Started by maximumrock, April 05, 2011, 06:09:29 PM

Previous topic - Next topic

jrstark


Owdy

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

HunterP

Quote from: HunterP on April 10, 2011, 12:55:20 PM
Quote from: IchBin™ on April 06, 2011, 12:07:02 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()

// 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 :

$context['show_by'] = $_SESSION['who_online_filter'] = 'members';

And "members" will be the default selection.

Shambles

Quote from: HunterP on October 16, 2011, 01:23:15 PM

Change the last line into :

$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

HunterP


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 :

// 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.

Advertisement: