SimplePortal

Customization => Custom Coding => Topic started by: bisbebri on November 28, 2009, 06:22:53 PM

Title: Total Time logged in
Post 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
Title: Re: Total Time logged in
Post by: ccbtimewiz on November 28, 2009, 08:35:00 PM
Code: [Select]
// 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'];
}
Title: Re: Total Time logged in
Post by: bisbebri on November 28, 2009, 08:38:14 PM
You're awesome, thank you very much sir. :)

-------
It doesnt show any thing when I add it to a PHP Block :(
Title: Re: Total Time logged in
Post by: ccbtimewiz on November 28, 2009, 08:43:26 PM
Lol, try this then:

Code: [Select]
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'];
      }
Title: Re: Total Time logged in
Post by: bisbebri on November 28, 2009, 08:45:12 PM
Worked wonders... Thank you
Title: Re: Total Time logged in
Post by: ccbtimewiz on November 28, 2009, 10:42:44 PM
No problem. :)
Title: Re: Total Time logged in
Post by: waruna on February 05, 2010, 03:06:37 PM
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
Title: Re: Total Time logged in
Post by: ccbtimewiz on February 05, 2010, 03:38:37 PM
This is for a new PHP block. You could modify the userinfo block if that is what you want.
SimplePortal 2.3.8 © 2008-2024, SimplePortal