News:

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

Main Menu

Total Time Logged In

Started by Matthew K., March 05, 2010, 03:34:33 AM

Previous topic - Next topic

Matthew K.

Link to Mod

Total Time Logged In v1.0
Displays the Total Time Logged In amount in the user info box at the top




Features

o Simply adds the 1.1 feature of displaying the "Total Time Logged In" amount in the user info box at the top
o Absolutely no configuration necessary; just install the Mod, and you're good to go!
o Supports SMF 2.0 RC2 (No back-porting to 1.1 since it has this option built in!)




Languages
-  No language files/edits! ;)



Changelog

Version 1.0 - January 31st, 2010
o Modification Release




All bug reports, feature requests, comments, and questions will be addressed on the Simple Machines website. Please do not redistribute un/modified versions of this mod without consent.

Enjoy!
~HaHa

Cal O'Shaw

Will this be updated for SMF 2.0?

Cal

Realinfo

I wanted to put total logged time on Right hand side, so I did that

// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">', sprintf($txt['welcome_guest'], $txt['guest_title']), '</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
<div class="info">', $txt['quick_login_dec'], '</div>';

if (!empty($modSettings['enableOpenID']))
echo '
<br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />';

echo '
<input type="hidden" name="hash_passwrd" value="" />
</form>';
}
echo '<br class="clear" />';
template_ad_position('above_info_guest_center');

echo '
</div>
<div class="news normaltext">
<form id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />&nbsp;
';

// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

echo '
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

echo '</form>';

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '

', $context['random_news_line'], '<br /><br />';

if (!empty($context['user']['total_time_logged_in']))
{
echo '
', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /><br />';
}
echo $context['current_time'], '



Everything is ok, but it shows "Total time logged in: 0 minutes." to guests what changes can hide it from guests?

in 2.0.4 default theme

Neo_TE

Actually you didn't add the code at the proper place. Remove what you did previously and then do the following edit.

Code (find) Select

<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';



Code (replace) Select

<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';
if (!empty($context['user']['total_time_logged_in']))
{
echo '
<li>', $txt['totalTimeLogged1'];

// If days is just zero, don't bother to show it.
if ($context['user']['total_time_logged_in']['days'] > 0)
echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];

// Same with hours - only show it if it's above zero.
if ($context['user']['total_time_logged_in']['hours'] > 0)
echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];

// But, let's always show minutes - Time wasted here: 0 minutes ;).
echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /></li>';
}


Realinfo

But i don't want it after show_unread_replies, and left hand side

I need it at Right hand side after Search and news

Just guide to hide it from guests

why it showing to guests ?

Neo_TE

Code (find) Select
if (!empty($context['user']['total_time_logged_in']))

Code (replace) Select
if (!empty($context['user']['total_time_logged_in']) && $context['user']['is_logged'])

Realinfo

Yes, this is the solution, thanks, now It's only for members

Neo_TE


Advertisement: