SimplePortal
Customization => Custom Coding => Topic started by: bisbebri on November 28, 2009, 06:22:53 PM
-
Could some one help me create a block that shows a users Total Time logged into the forums. Thanks
-
// Show the total time logged in?
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'];
}
-
You're awesome, thank you very much sir. :)
-------
It doesnt show any thing when I add it to a PHP Block :(
-
Lol, try this then:
global $context, $txt;
// Show the total time logged in?
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'];
}
-
Worked wonders... Thank you
-
No problem. :)
-
Dear ccbtimewiz, can you teach me how to add the code? which file should I open? And it will show the total time logged in underneath the 'Show new replies to your posts.' right?
Thanks in advance
-
This is for a new PHP block. You could modify the userinfo block if that is what you want.