News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Users Online Today Mod

Started by Nibogo, November 06, 2005, 01:42:31 AM

Previous topic - Next topic

Bigguy

Those lines are from the modifications.english.php file and the problem probably is that the
?> is not at the end of the file or those lines are after the ?> open up that file and make sure that ?> is at the very end of the file. That should get rid of the text.

If it won't uninstall then you will have to manually remove the code. All the edits can be found in the .xml file of the package. (Not the package-info.xml the other .xml file)

Peter_Roehlen

Okay, thanks BG, I'll give it a shot.

veldfire


symon

Can anyone please answer me a few questions straight pweeeeeeze :)

1: I'm used to manually installing mods but there is nowhere to edit the boardindex.template in Babylon. This is surprising as the Babylon theme was the old default theme.

2: Will this show (including guests) the number of visitors online in 24 hours? NOT the most online together which they all seem to do?

Ta for your help in advance...

:)

symon

#604
Added it to Babylon

Ok...I found this myself as it's not greatly difficult. ;) But rather than go "It's ok...I solved it" I thought I'd show you what I did ;)

I found this code in babylon/Boardindex.template.php:

// "Users online" - in order of activity.
echo '
<tr>
<td class="catbg" colspan="2">', $txt[158], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt[158], '" border="0" />', $context['show_who'] ? '</a>' : '', '
</td>
<td class="windowbg2" width="100%">';

if ($context['show_who'])
echo '
<a href="', $scripturl, '?action=who">';

echo $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];


// Handle hidden users and buddies.
if (!empty($context['num_users_hidden']) || ($context['show_buddies'] && !empty($context['show_buddies'])))
{
echo ' (';

// Show the number of buddies online?
if ($context['show_buddies'])
echo $context['num_buddies'], ' ', $context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies'];

// How about hidden users?
if (!empty($context['num_users_hidden']))
echo $context['show_buddies'] ? ', ' : '', $context['num_users_hidden'] . ' ' . $txt['hidden'];

echo ')';
}

if ($context['show_who'])
echo '</a>';

echo '
<div class="smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
echo '
', $txt[140], ':<br />', implode(', ', $context['list_users_online']);

echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr>


And added after it:



<tr>
<td class="windowbg" width="20" valign="middle" align="center">
</td>
<td class="windowbg2" width="100%">
<div class="smalltext">', $txt['most_online_today'], ': <b>', $modSettings['mostOnlineToday'], '</b>.
', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
</div>
</td>
</tr>';

// Users online today

echo '
<tr>
<td class="titlebg" colspan="2">', $txt['uot_users_online_today'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt['uot_users_online_today'], '" border="0" />
</td>
<td class="windowbg2" width="100%">';

echo '
<div class="smalltext">';

  echo $txt['uot_total'], ': <b>', $context['num_users_online_today'], '</b>';
  if (!$context['user']['is_guest'])
  echo ' (', $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_hidden_users_online_today']), ', ', $txt['uot_hidden'], ': ', $context['num_hidden_users_online_today'], ')';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && !$context['user']['is_guest'])
echo '<br />', implode(', ', $context['list_users_online_today']);

echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr>';


In the added code I changed:

<td class="titlebg" colspan="2">', $txt['uot_users_online_today'], '</td>

To:

<td class="catbg" colspan="2">', $txt['uot_users_online_today'], '</td>

Does this look ok to you experienced coders? It works great now :)

symon

This works fantastically now.

But does anyone know how to make it show the 'total online today' number include guests also?

The reason I ask this is because I get about 2000 visitors a day and the amount of members online in a day is much less.

Is it possible? :)

symon

OK, to add guests to the stats at the foot of the page I have this so far...

Bearing in mind $context['num_total_guests'] is not the right function, nor real (I'm hoping you guys in the know will help), I've added it in the right places using $context[''num_guests''] in the produced site so it actually runs. But obviously $context[''num_guests''] just gives the guests on at that time.

So this is cosmetic until anyone can help :)

Modifications.English.php add to the end:

$txt['uot_guests']='Guests';

Add to BoardIndex.php:

$context['num_users_online_today'] = count($context['users_online_today']);
if (!$user_info['is_admin'])
{
$context['num_users_online_today'] = $context['num_users_online_today'] + $context['num_hidden_users_online_today'] + $context[''num_total_guests''];
}


Add to BoardIndex.template.php:

  echo $txt['uot_total'], ': <b>', $context['num_users_online_today'], '</b>';
  if (!$context['user']['is_guest'])
  echo ' (', $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_hidden_users_online_today']), ', ', $txt['uot_guests'], ': ', $context['num_total_guests'], ', ', $txt['uot_hidden'], ': ', $context['num_hidden_users_online_today'], ')';


This all displays fine but I'm out of my depth for writing the fetch from database stuff and writing a real $context['num_total_guests'] function that returns the whole days guest numbers.

Does that make sense? Can anyone help with this?

:)

symon

Is there just a function and a DB table needed to make this work?

It would make this mod complete.  I'm suprised it's not considered :)

Vanterax

Quick question about the mod.

I got it installed and working.  It's beautiful!  However, it seems to build the list of user logged on today according to the server time.  I don't know where my server is located physically, but the list of user who logged on today starts at 8am EST for me.  So here's my question:

Is there a way for the list of user to be built according to my midnight and not the server's?  In other words, using the user's time offset?

Vanterax

#609
Hmmm...  Maybe I should've read your code before making this request...

$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);



You seem to be already doing this.  However, it doesn't seem to work on my end.  I hate dealing with time. :)

EDIT:  I removed the "- ($modSettings['time_offset'] * 3600);" part and now it's showing up the list fine.  It's very odd.

EDIT2: I think I know what was wrong.  The forum itself had an overall time offset for all users and the mod doesn't take that into account.  Unsetting it resolved it.  :)

farzad

any thought to add logged in users AND guest counts to this mod instead of just users that have logged in?


symon

I'll have a go if someone helps me write the correct DB table.

Or maybe the creator of this mod doesn't want it meddled with ;)

symon

Is offering to help make something better a bad thing on the SMF forum?

Just it's gone very quiet...even by busy standards :D

farzad

#613
i have no skills to help, however  i doubt the open source nature of SMF and the mod would not prohibit you from enhancing or experimenting with it.

symon

Well I wrote the display side of things in previous posts but I too haven't the skills to write the function and DB table to make it work LOL.

It would make this mod complete rather than a bit open-ended and be an impressive stat to have on the sites.

symon

At what point is the uot_yesterday part used? It doesn't display anywhere and would be handy :)

Photoshocker

#616
Edit. Found it.

alo

Quote from: symon on March 12, 2007, 07:00:38 PM
Added it to Babylon

Ok...I found this myself as it's not greatly difficult. ;) But rather than go "It's ok...I solved it" I thought I'd show you what I did ;)

I found this code in babylon/Boardindex.template.php:

// "Users online" - in order of activity.
echo '
<tr>
<td class="catbg" colspan="2">', $txt[158], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt[158], '" border="0" />', $context['show_who'] ? '</a>' : '', '
</td>
<td class="windowbg2" width="100%">';

if ($context['show_who'])
echo '
<a href="', $scripturl, '?action=who">';

echo $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];


// Handle hidden users and buddies.
if (!empty($context['num_users_hidden']) || ($context['show_buddies'] && !empty($context['show_buddies'])))
{
echo ' (';

// Show the number of buddies online?
if ($context['show_buddies'])
echo $context['num_buddies'], ' ', $context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies'];

// How about hidden users?
if (!empty($context['num_users_hidden']))
echo $context['show_buddies'] ? ', ' : '', $context['num_users_hidden'] . ' ' . $txt['hidden'];

echo ')';
}

if ($context['show_who'])
echo '</a>';

echo '
<div class="smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
echo '
', $txt[140], ':<br />', implode(', ', $context['list_users_online']);

echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr>


And added after it:



<tr>
<td class="windowbg" width="20" valign="middle" align="center">
</td>
<td class="windowbg2" width="100%">
<div class="smalltext">', $txt['most_online_today'], ': <b>', $modSettings['mostOnlineToday'], '</b>.
', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
</div>
</td>
</tr>';

// Users online today

echo '
<tr>
<td class="titlebg" colspan="2">', $txt['uot_users_online_today'], '</td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center">
<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt['uot_users_online_today'], '" border="0" />
</td>
<td class="windowbg2" width="100%">';

echo '
<div class="smalltext">';

  echo $txt['uot_total'], ': <b>', $context['num_users_online_today'], '</b>';
  if (!$context['user']['is_guest'])
  echo ' (', $txt['uot_visible'], ': ', ($context['num_users_online_today'] - $context['num_hidden_users_online_today']), ', ', $txt['uot_hidden'], ': ', $context['num_hidden_users_online_today'], ')';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online_today']) && !$context['user']['is_guest'])
echo '<br />', implode(', ', $context['list_users_online_today']);

echo '
<br />', $context['show_stats'] && !$settings['show_sp1_info'] ? '
<a href="' . $scripturl . '?action=stats">' . $txt['smf223'] . '</a>' : '', '
</div>
</td>
</tr>';


In the added code I changed:

<td class="titlebg" colspan="2">', $txt['uot_users_online_today'], '</td>

To:

<td class="catbg" colspan="2">', $txt['uot_users_online_today'], '</td>

Does this look ok to you experienced coders? It works great now :)
how to show names of users online to guests? it shown number of user online only

symon

Quote from: alo on March 24, 2007, 05:19:06 AM
how to show names of users online to guests? it shown number of user online only

Hey,

Did you add all of the code to all of the files including the Boardindex.template.php in the default theme folder as well as the Babylon theme? The code I've done is ONLY for the babylon Boardindex.template.php. The code for the default theme is with the package. :)

I'll try and help as much as I can but my expertise is limited (it's not even expertise! lol)

alo

Quote from: symon on March 24, 2007, 11:48:02 AM
Quote from: alo on March 24, 2007, 05:19:06 AM
how to show names of users online to guests? it shown number of user online only

Hey,

Did you add all of the code to all of the files including the Boardindex.template.php in the default theme folder as well as the Babylon theme? The code I've done is ONLY for the babylon Boardindex.template.php. The code for the default theme is with the package. :)

I'll try and help as much as I can but my expertise is limited (it's not even expertise! lol)
i'm using another theme...not the babylon theme

Advertisement: