SimplePortal
Customization => Custom Coding => Topic started 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)
-
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!
-
Thanks for your support Rad :)
-
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">
-
So that would create the exact same styled who's online list as the forums default?
-
not entirely the same as the forums default, but will give you a horizontal look, the same as SP block but horizontal
-
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.
-
ok, on a php block copy an paste this:
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('] [', $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>';
-
(http://i26.tinypic.com/30axlrk.png)
Thats how it goes, doesn't work at all :(
-
I forgot to globalize $modSettings
use this one
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('] [', $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>';
-
Doesn't display me as online or show my name :dead:
-
can I have a link to your forum please?
-
http://www.profifaleagues.net/index.php
-
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
-
ok, let me check as the code above its just a copy/paste from BoardIndex.template.
to remove the little people just remove this:
', $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>' : '', '
-
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.
-
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 ?
-
ok, let me check as the code above its just a copy/paste from BoardIndex.template.
to remove the little people just remove this:
', $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?
-
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.
-
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?
-
give this a shot, create a custom PHP block and add this code to it.
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 />';
}
-
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!