SimplePortal

Customization => Custom Coding => Topic started by: Nick on July 18, 2010, 03:51:52 PM

Title: Who's Online Block
Post by: Nick on July 18, 2010, 03:51:52 PM
How do i change the "Who's online" block from the layout it currently has to the default forum layout where the names are side by side and go across width ways.

Like this;

(http://i26.tinypic.com/168ie4l.png)
Title: Re: Who's Online Block
Post by: rad1701 on July 24, 2010, 10:40:27 PM
I would also like something like this a lot too.  I want to put my Who's Online block on top of my forum in the Center Block.  So, I want the "Who's Online" list to run horizontally so it won't take up so much space.

- Thanks

P.S.  Love Simple Portal!
Title: Re: Who's Online Block
Post by: Nick on July 28, 2010, 08:55:17 AM
Thanks for your support Rad :)
Title: Re: Who's Online Block
Post by: 130860 on July 28, 2010, 09:17:20 AM
look on Sources/Portalblocks.php   the function   function sp_whosOnline

below this:

$stats = ssi_whosOnline('array');

   echo '

you will see its only a html list, so, changing the html will get your block horizontally. it may be even done with pure css  by creating a new class with:  display: inline;


this is an example:


.myclass li
{
display: inline;
list-style-type: none;
padding-right: 20px;
}

and change in PortalBlocks.php  within function sp_whosOnline :

<ul class="sp_list">

to

<ul class="myclass">


Title: Re: Who's Online Block
Post by: Nick on July 29, 2010, 07:16:43 PM
So that would create the exact same styled who's online list as the forums default?
Title: Re: Who's Online Block
Post by: 130860 on July 29, 2010, 08:56:01 PM
not entirely the same as the forums default, but will give you a horizontal look, the same as SP block but horizontal
Title: Re: Who's Online Block
Post by: Nick on July 30, 2010, 06:46:37 AM
Thanks i will take a look :).

EDIT: I added and it's still not want i want really. I would prefer the default forum look.
Title: Re: Who's Online Block
Post by: 130860 on July 30, 2010, 10:09:12 AM
ok, on a php block copy an paste this:

Code: (php) [Select]
global $context, $txt, $settings;

// "Users online" - in order of activity.
echo '


<span class="ie6_header floatleft">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '
</span>
</h4>

<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>' : '', '
</p>
<p class="inline smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
}

echo '
</p>
<p class="last smalltext">
', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>.
', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')
</p>';
Title: Re: Who's Online Block
Post by: Nick on July 30, 2010, 01:35:46 PM
(http://i26.tinypic.com/30axlrk.png)

Thats how it goes, doesn't work at all :(
Title: Re: Who's Online Block
Post by: 130860 on July 30, 2010, 03:34:11 PM
I forgot to globalize $modSettings

use this one

Code: [Select]
global $context, $txt, $settings, $modSettings;

// "Users online" - in order of activity.
echo '


', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
', $txt['online_users'], '



<p class="inline stats">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', comma_format($context['num_guests']), ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . comma_format($context['num_users_online']), ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>' : '', '
</p>
<p class="inline smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
}

echo '
</p>
<p class="last smalltext">
', $txt['most_online_today'], ': <strong>', comma_format($modSettings['mostOnlineToday']), '</strong>.
', $txt['most_online_ever'], ': ', comma_format($modSettings['mostOnline']), ' (', timeformat($modSettings['mostDate']), ')
</p>';
Title: Re: Who's Online Block
Post by: Nick on July 30, 2010, 04:49:56 PM
Doesn't display me as online or show my name  :dead:
Title: Re: Who's Online Block
Post by: 130860 on July 30, 2010, 05:01:43 PM
can I have a link to your forum please?
Title: Re: Who's Online Block
Post by: Nick on July 30, 2010, 05:11:29 PM
http://www.profifaleagues.net/index.php
Title: Re: Who's Online Block
Post by: rad1701 on July 30, 2010, 07:54:20 PM
Ok, that last code is pretty much working for me.  A question though.  Is there a way to not have it show that little people icon link?  Takes up a bit of space and not really needed for me.  Also, why is there a little colon above the names?  Can that be removed?  Here's how it's looking on the top of my forum over at:  http://www.treksinscifi.com/forum/index.php

(http://www.treksinscifi.com/images/tsf_userson1.jpg)

P.S.  Oh, I just noticed one more thing.  This shows up fine when on the main forum/index.php page.  But when I look at a forum post, the display shows 0, 0 (meaning no one online).  I have the block set to show everywhere too.

- thanks
Title: Re: Who's Online Block
Post by: 130860 on July 30, 2010, 09:27:40 PM
ok, let me check as the code above its just a copy/paste from BoardIndex.template.

to remove the little people just remove this:

Code: [Select]
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
Title: Re: Who's Online Block
Post by: rad1701 on July 30, 2010, 10:57:53 PM
Ok, that's a help.  Any idea why the number of users and guests goes to zero when inside the forum?  Also, still would like to have the colon gone.
Title: Re: Who's Online Block
Post by: Nick on July 31, 2010, 07:58:53 AM
Mines going to be just set to the portal page but as you can see i'm signed in but it doesn't display Users :1 and my name :S ?
Title: Re: Who's Online Block
Post by: dsantana on August 12, 2010, 10:44:30 AM
ok, let me check as the code above its just a copy/paste from BoardIndex.template.

to remove the little people just remove this:

Code: [Select]
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who' . '">' : '', '<img class="icon" src="', $settings['images_url'], '/icons/online.gif', '" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '

Can I also change that code to show my own image?
Title: Re: Who's Online Block
Post by: AngelinaBelle on August 20, 2010, 11:42:20 AM
http://w3schools.com/php/default.asp (http://w3schools.com/php/default.asp) will help you get started -- reading and understanding the code will be easier.
http://w3schools.com/html/default.asp (http://w3schools.com/html/default.asp) if you want an HTML refresher.
 
Most of the time, the variable names and array indices make some kind of sense, so you can often figure out "where's that image I want to replace".
Also, you can spot the HTML "<img" tag, for example.
 
On a PC, the command line find command helps you search a whole directory full of php files at once for something you are looking for.
 
 
Title: Re: Who's Online Block
Post by: TattooMasters on June 15, 2011, 02:41:43 PM
Mines going to be just set to the portal page but as you can see i'm signed in but it doesn't display Users :1 and my name :S ?

I have that problem too. What do I have to do to make it count the guests and members online including showing the names?
Title: Re: Who's Online Block
Post by: cloksin on June 19, 2011, 01:42:58 AM
give this a shot, create a custom PHP block and add this code to it.

Code: [Select]
global $txt, $modSettings, $scripturl, $context, $sourcedir, $settings;

if (!$user_info['is_guest']) {
echo '<a href="', $scripturl, '?action=profile;area=notification;">Topics - You\'re Watching</a><br />';
echo '<a href="', $scripturl, '?action=bookmarks">Topics - You\'ve Bookmarked</a><br />';

echo '<hr>';

// Get the user online list.
require_once($sourcedir . '/Subs-MembersOnline.php');
$membersOnlineOptions = array(
'show_hidden' => allowedTo('moderate_forum'),
'sort' => 'log_time',
'reverse_sort' => true,
);
$context += getMembersOnlineStats($membersOnlineOptions);

// "Users online" - in order of activity.
echo ' <a href="' . $scripturl . '?action=who">Who\'s Online</a><br />';
echo '
<div class="infocenter_section">
<div class="windowbg">
<div>
', $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'],' ', '(' . $context['num_users_hidden'], ' ', $context['num_users_hidden'] == 1 ? $txt['hidden'] : $txt['hidden'], ')';

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = $context['num_buddies'] . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
//if (!empty($context['num_users_hidden']))
//$bracketList[] = $context['num_users_hidden'] . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>': '', '
<div class="smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

echo '
</div>
<hr />
<div class="smalltext">';

// Showing membergroups?

$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());

if (!empty($settings['show_group_key']) && !empty($context['membergroups']))

echo '

[' . implode('][', $context['membergroups']) . ']';

}

echo '
</div>
<hr />
<div class="smalltext">
', $txt['most_online_today'], ': <b>', $modSettings['mostOnlineToday'], '</b>.
', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
</div>
</div>
</div>
</div>';
echo '<hr>';

}

// Admin only
if ($user_info['is_admin']) {
echo '<a href="', $scripturl , '?action=admin;area=viewmembers;sa=browse;type=activate', '">', sprintf($txt['admin_browse_awaiting_activate'], $context['awaiting_activation']), '</a><br />';
}
Title: Re: Who's Online Block
Post by: TattooMasters on June 19, 2011, 03:43:25 AM
That's almost what I was looking for!

How do I loose the grey backround and make it transparant with my portal?

Edit:

After some adjustments that I made by fooling around my endresult is there. Thank you so much for your help!
SimplePortal 2.3.8 © 2008-2024, SimplePortal