SimplePortal
Customization => Custom Coding => Topic started 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.
-
What's your SMF version? It's hard to guess when we support two versions.
-
1.1.8
-
I went in my TP test site, and got this code:
// 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.
-
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.
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>';
-
Just to note; this is already implemented in 2.2 version, but it is not out yet. ;)
-
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.
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 ;)
-
He's L. :P
-
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.
-
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.
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?
-
Check your error logs, there should be an error shown when you hit that white page.
-
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:
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
-
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 ..
-
Just be patient, you'll be able to see for yourself when it's released.
-
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.
-
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