Customizing SMF > Tips and Tricks
[TRICK] displaying the "unknown action" in the who's online list
Kindred:
so, you have a bunch of mods installed and 90% of them - while they add functionality to your forum - don't add themselves into the list of valid actions in the Who's Online list.
This little trick won't fix ALL of the problems (it's a quick trick, it doesn't drill down into special actions or sub-actions) but it will, at least, display where the user actually IS in your system.
--- Code: (find in Sources/Who.php) ---function determineActions($urls, $preferred_prefix = false)
{
global $txt, $user_info, $modSettings, $smcFunc, $context;
--- End code ---
--- Code: (add after) ---global $scripturl;
--- End code ---
--- Code: (find in Sources/who.php) ---// Unlisted or unknown action.
else
$data[$k] = $txt['who_unknown'];
--- End code ---
--- Code: (replace) ---// Unlisted or unknown action.
else
$data[$k] = $txt['who_thisaction'] . '<a href="' . $scripturl . '?action=' . $actions['action'] . '">' . $actions['action'] . '</a>';
--- End code ---
then add the following text string to modifications.YOURLANGUAGE.txt
--- Code: ---$txt['who_thisaction'] = 'Viewing the ';
--- End code ---
Kindred:
note: I have been playing with the following, but it doesn't quite work....
--- Code: ---// Unlisted or unknown action.
else {
if (isset($actions['sa'])) {
$extraaction['sa']['text'] = ' - ' . $actions['sa'];
$extraaction['sa']['url'] = ';sa=' . $actions['sa'];
} else {
$extraaction['sa']['text'] = '';
$extraaction['sa']['url'] = '';
}
if (isset($actions['area'])) {
$extraaction['area']['text'] = ' - ' . $actions['area'];
$extraaction['area']['url'] = ';area=' . $actions['area'];
} else {
$extraaction['area']['text'] = '';
$extraaction['area']['url'] = '';
}
if (isset($actions['u'])) {
$extraaction['u']['text'] = ' for User ID' . $actions['u'];
$extraaction['u']['url'] = ';u=' . $actions['u'];
} else {
$extraaction['u']['text'] = '';
$extraaction['u']['url'] = '';
}
if (isset($actions['cat'])) {
$extraaction['cat']['text'] = ' in Category' . $actions['cat'];
$extraaction['cat']['url'] = ';cat=' . $actions['cat'];
} else {
$extraaction['cat']['text'] = '';
$extraaction['cat']['url'] = '';
}
$data[$k] = 'Viewing the <a href="' . $scripturl . '?action=' . $actions['action'] . $extraaction['sa']['url'] . $extraaction['area']['url'] . $extraaction['u']['url'] . $extraaction['cat']['url'] .'">' . $actions['action'] . $extraaction['sa']['text'] . $extraaction['area']['text'] . $extraaction['u']['text'] . $extraaction['cat']['text'] . '</a>';
}
--- End code ---
Labradoodle-360:
Very neat, Kindred...it'd be cool if eventually SMF had this implemented into the core so modifications didn't HAVE to.
nza2k:
Thank you Kindred,
Is there any way, without killing the sever, to display real time stats instead of a list of names.
For instance :
- 5 members and 1 moderator are watching post 1
- 7 members are watching post 2
- 3 members are connecting
- 1 member is posting a new message
...
?
Kindred:
that would require a whole bunch more recoding... my trick is just to replace the frustrating "unknown action"
Navigation
[0] Message Index
[#] Next page
Go to full version