SimplePortal

Customization => Custom Coding => Topic started by: codnerd on February 18, 2009, 06:10:00 AM

Title: Users Online Shortening
Post by: codnerd on February 18, 2009, 06:10:00 AM
I usually have about 100 or over users on at one time. How do I edit the "Who's Online" block, so that it will show about 20 of them, and then it will have a scroll bar to see the rest.
Title: Re: Users Online Shortening
Post by: [SiNaN] on February 18, 2009, 06:23:08 AM
What's your SMF version? It's hard to guess when we support two versions.
Title: Re: Users Online Shortening
Post by: codnerd on February 18, 2009, 03:50:06 PM
1.1.8
Title: Re: Users Online Shortening
Post by: codnerd on February 18, 2009, 09:54:15 PM
I went in my TP test site, and got this code:

Code: [Select]
// add online users
echo '
<h5 class="online"><a href="'.$scripturl.'?action=who">'.$txt[158].'</a></h5>
<ul>
<li>';

$online = ssi_whosOnline('array');
echo $txt['tp-users'].': '.$online['num_users']. '
</li>
<li>'.$txt['tp-guests'].': '.$online['guests'].'</li>
<li>'.$txt['tp-total'].': '.$online['total_users'].'</li>
<li style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

foreach($online['users'] as $user)
{
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
}
echo '
</li>
</ul>';

Then I pasted it in my PHP SP Block, and it worked.
Title: Re: Users Online Shortening
Post by: Nathaniel on February 19, 2009, 12:19:16 AM
Um, I would be suprised if that code worked in a SP block, for several reasons. Although if you have tp installed as well then it might.

The block code below should work for SimplePortal, set the $limit variable to a different number to limit the number of users shown.
Code: [Select]
      global $txt, $scripturl;
      require_once('SSI.php');

     $limit = 20; // Limited number of users shown.

      // add online users
      echo '
      <h5 class="online"><a href="'.$scripturl.'?action=who">'.$txt[158].'</a></h5>
      <ul>
         <li>';
     
      $online = ssi_whosOnline('array');
      echo $txt['sp-onlineuser'].': '.$online['num_users']. '
         </li>
         <li>'.$txt['sp-onlineguest'].': '.$online['guests'].'</li>
         <li>'.$txt['sp-onlinetuser'].': '.$online['total_users'].'</li>
         <li style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user)
      {
         if ($limit <= 0)
               break;
         echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
         echo '<br />';
         $limit--;
      }
      echo '
         </li>
      </ul>';
Title: Re: Users Online Shortening
Post by: [SiNaN] on February 19, 2009, 03:01:44 AM
Just to note; this is already implemented in 2.2 version, but it is not out yet. ;)
Title: Re: Users Online Shortening
Post by: grafitus on February 23, 2009, 11:36:04 AM
Um, I would be suprised if that code worked in a SP block, for several reasons. Although if you have tp installed as well then it might.

The block code below should work for SimplePortal, set the $limit variable to a different number to limit the number of users shown.
Code: [Select]
      global $txt, $scripturl;
      require_once('SSI.php');

     $limit = 20; // Limited number of users shown.

      // add online users
      echo '
      <h5 class="online"><a href="'.$scripturl.'?action=who">'.$txt[158].'</a></h5>
      <ul>
         <li>';
     
      $online = ssi_whosOnline('array');
      echo $txt['sp-onlineuser'].': '.$online['num_users']. '
         </li>
         <li>'.$txt['sp-onlineguest'].': '.$online['guests'].'</li>
         <li>'.$txt['sp-onlinetuser'].': '.$online['total_users'].'</li>
         <li style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user)
      {
         if ($limit <= 0)
               break;
         echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
         echo '<br />';
         $limit--;
      }
      echo '
         </li>
      </ul>';

Thanks Blue Dream ;)
Title: Re: Users Online Shortening
Post by: [SiNaN] on February 24, 2009, 08:27:35 AM
He's L. :P
Title: Re: Users Online Shortening
Post by: Aw06 on February 28, 2009, 02:02:11 PM
I just tried this .. i set the limit to 5, it does not show the scroll bar ... Also, i dont want another PHP block, i want to hardcode it into the existing whos online Simple portal block.
Title: Re: Users Online Shortening
Post by: Manu on February 28, 2009, 03:31:21 PM
Um, I would be suprised if that code worked in a SP block, for several reasons. Although if you have tp installed as well then it might.

The block code below should work for SimplePortal, set the $limit variable to a different number to limit the number of users shown.
Code: [Select]
      global $txt, $scripturl;
      require_once('SSI.php');

     $limit = 20; // Limited number of users shown.

      // add online users
      echo '
      <h5 class="online"><a href="'.$scripturl.'?action=who">'.$txt[158].'</a></h5>
      <ul>
         <li>';
     
      $online = ssi_whosOnline('array');
      echo $txt['sp-onlineuser'].': '.$online['num_users']. '
         </li>
         <li>'.$txt['sp-onlineguest'].': '.$online['guests'].'</li>
         <li>'.$txt['sp-onlinetuser'].': '.$online['total_users'].'</li>
         <li style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user)
      {
         if ($limit <= 0)
               break;
         echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
         echo '<br />';
         $limit--;
      }
      echo '
         </li>
      </ul>';
When I insert this code in a php-block it's causing me a white page, what's wrong with it?
Title: Re: Users Online Shortening
Post by: Eliana Tamerin on February 28, 2009, 03:41:41 PM
Check your error logs, there should be an error shown when you hit that white page.
Title: Re: Users Online Shortening
Post by: Manu on February 28, 2009, 03:54:53 PM
Check your error logs, there should be an error shown when you hit that white page.

Yes I have an entry in my error log:

Code: [Select]
Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.smf_fc_connections AS fc
LEFT JOIN smf_members AS mem ON (mem.ID_MEMBER = fc' at line 6
File: /is/.../.../.../forum/SSI.php
Line: 735
Title: Re: Users Online Shortening
Post by: Aw06 on March 02, 2009, 07:38:41 AM
Just to note; this is already implemented in 2.2 version, but it is not out yet. ;)

Can you give an example, can you set the limit to 3, so i can see how the scroll bar looks on this site ..
Title: Re: Users Online Shortening
Post by: Eliana Tamerin on March 02, 2009, 07:46:24 AM
Just be patient, you'll be able to see for yourself when it's released.
Title: Re: Users Online Shortening
Post by: Aw06 on March 02, 2009, 08:01:18 AM
Just be patient, you'll be able to see for yourself when it's released.

that might be abit too late ... what is there are tips users can give now to help compliment it.
Title: Re: Users Online Shortening
Post by: Aw06 on March 03, 2009, 09:12:31 AM
I also hope this is being added to all custom blocks, where in i can specify a cut off number of charactors and SP will add the scroll bar thereafter
SimplePortal 2.3.8 © 2008-2024, SimplePortal