SimplePortal

Support => English Support => Topic started by: Racketydoo on May 01, 2016, 07:43:26 PM

Title: Staff List
Post by: Racketydoo on May 01, 2016, 07:43:26 PM
I've been trying to use a couple of SP blocks/mods to identify a non-moderator group to the Staff List.

Using [Block] Show Members (in staff block style) (http://simpleportal.net/index.php?topic=14168.0) seemed easiest to me, so I added the block. It populates a single member from a multiple-member membergroup and then cuts off at the first divider.

My understanding of code being non-existent and my ability to trouble shoot being very, very limited, I deleted the block and instead installed New Staff Block (http://simpleportal.net/index.php?topic=8765.0).

I uploaded it via the Package Manager, added membergroups 2 and 8 and it (apparently) worked perfectly - the right members were displayed in the box with the correct avatar - all seemed well.  However, the following day I found 4k+ errors in the Error Log of the same two errors:
8: Undefined index: id
File: /Forum/Sources/PortalBlocks.php
Line: 2378

2: Illegal string offset 'group'
File: /Forum/Sources/PortalBlocks.php
Line: 2371

If anyone would be willing to point me in the right direction to either get the Show Members block or the New Staff block working correctly, I'd be most appreciative.  :thumbsup:

Many thanks.

(PS: I also tried Add Membergroups to the Staff Block Plugin (http://simpleportal.net/index.php?topic=10209.0) but there was an issue with installation so I followed the, "Don't proceed if you have no clue what you're doing" advisory and didn't proceed any further with it.  ;D)

Simple Portal 2.3.6
SMF 2.0.11
Title: Re: Staff List
Post by: ♦ Ninja ZX-10RR ♦ on May 01, 2016, 08:45:39 PM
Hi,

try this one: http://simpleportal.net/index.php?topic=14168.0
Also, thank you for putting in so many details! It really helps us help you! :)

Regards
Title: Re: Staff List
Post by: Racketydoo on May 01, 2016, 11:52:44 PM
Thank you for your reply, Ninja.

Unfortunately though, the link you gave me was the first option I tried.  :|

It populates one member from a multi-member membergroup, but the block cuts off at the first divider underneath that member. As a result I can't determine if it is populating with more than one member after that divider.

I'm not attached to any particular block or plugin to achieve the end result. If it can produce the result of adding non-moderator members/membergroups  to the staff list block in some form (within my limited capabilities) I'd see that as a win.  :nervous-happy:

Many thanks for trying to help me. I appreciate it.
Title: Re: Staff List
Post by: ♦ Ninja ZX-10RR ♦ on May 02, 2016, 11:19:58 AM
*facepalm* congratulations to me for the most stupid reply since I registered ;D
Sorry man, I was really sleepy and in a hurry when I replied, so I probably either misclicked the link or didn't check it correctly or whatever :/ If you post your FULL  code block then I may have a look, you probably missing a comma or something like that.
Also, what is your php version? https://mediatemple.net/community/products/dv/204643880/how-can-i-create-a-phpinfo.php-page
Title: Re: Staff List
Post by: Racketydoo on May 02, 2016, 03:12:35 PM
It's all good! I was glad to receive a reply.  :thumbsup:

My PHP version: PHP 5.3.29

1. For the block by Maizono:
I copied the code directly from here: Show Members in staff block (http://simpleportal.net/index.php?topic=14168.0). I pasted it into a new php block.
Code: [Select]
<?php

/**
 * @block Show Members
 * @author Rhode Fey (Sayaka Maizono)
 * @version 1.0.2
*/

/*
Usage:
fill the array with group ids of the groups you want to show.
Example for showing just one group, from group 1;
$groups_to_use = array(1);
Example for showing three groups, from group 1, 3, and 8
$groups_to_use = array(1, 3, 8);
*/

$groups_to_use = array(1);

/*
Usage:
fill the array with member ids you don't want to show up.
Example for hiding one member, user #1
$members_to_ignore = array(1);
Example for hiding multiple members, user #1, #3, and #8
$members_to_ignore = array(1, 3, 8);
*/

$members_to_ignore = array();

/*
 *
*/

global $smcFunc$sourcedir$scripturl$modSettings$txt;

// These are strings for errors...
$txt['no_groups'] = 'No groups have been defined! Please refer to the comments in the Block code!';
$txt['no_members'] = 'No members have been found...';

$groups = array();
foreach (
$groups_to_use as $group)
$groups[] = (int) $group;
$groups array_unique($groups);

$ignored_members = array();
foreach (
$members_to_ignore as $id)
$ignored_members[] = (int) $id;
$ignored_members array_unique($ignored_members);

if (empty(
$groups))
{
echo '
<span class="smalltext" style="color: red;">
'
$txt['no_groups'] . '
</span>'
;

return;
}

$request $smcFunc['db_query']('''
SELECT
mem.id_member, mem.real_name, mem.avatar, mem.id_group, mem.id_post_group, mg.group_name,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_group_id} THEN mem.id_post_group ELSE mem.id_group END)
WHERE mem.id_group IN ({array_int:groups_to_use}) OR mem.id_post_group IN ({array_int:groups_to_use})'
,
array(
'groups_to_use' => $groups,
'reg_group_id' => 0,
)
);

$member_list = array();
while (
$row $smcFunc['db_fetch_assoc']($request))
{
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' $modSettings['avatar_max_width_external'] . '"' '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' $modSettings['avatar_max_height_external'] . '"' '';
}
else
{
$avatar_width '';
$avatar_height '';
}

$member_list[$row['id_member']] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'link' => '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['real_name'] . '</a>',
'group' => $row['group_name'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > '<img src="' . (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) . '" alt="" class="avatar" border="0" />' '') : (stristr($row['avatar'], 'http://') ? '<img src="' $row['avatar'] . '"' $avatar_width $avatar_height ' alt="" class="avatar" border="0" />' '<img src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > ? (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
'url' => $row['avatar'] == '' '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);

if (empty(
$member_list))
{
echo '
<span class="smalltext" style="color: red;">
'
$txt['no_members'] . '
</span>'
;

return;
}

ksort($member_list);
$member_count count($member_list);
$count 0;

echo 
'
<table class="sp_fullwidth">'
;

foreach (
$member_list as $member)
{
if (!empty($ignored_members))
if (in_array($member['id'], $ignored_members))
return;

echo '
<tr>
<td class="sp_staff sp_center">'
, !empty($member['avatar']['href']) ? '<a href="' $scripturl '?action=profile;u=' $member['id'] . '"><img src="' $member['avatar']['href'] . '" alt="' $member['name'] . '" width="40" /></a>' '''</td>
<td class="sp_staff_info'
$member_count != ++$count ' sp_staff_divider' '''">
'
$member['link'], '<br />
'
$member['group'], '
</td>
</tr>'
;

echo '
</table>'
;
}

?>

Looking at it again today, I can see by using the preview function that the block is correctly populating multiple members from various multi-member lists. The issue seems to be how it displays, not how it populates: the divider is cutting off the block after the first member is listed.

2. For the mod by Grafitus:
I installed the zip file. I did see similar issues described within the thread but assumed file newstaffblock_1.1.zip (http://simpleportal.net/index.php?action=dlattach;topic=8765.0;attach=5202) contained the fix (that link is the zip link, btw). As I say, this works perfectly at the front end, but returns the errors I posted.

Thank you for your help again, Ninja.  :nervous-happy:
Title: Re: Staff List
Post by: ♦ Ninja ZX-10RR ♦ on May 02, 2016, 04:46:18 PM
Which groups do you want it to show up? Site URL to see it live?
Title: Re: Staff List
Post by: emanuele on May 03, 2016, 03:04:53 AM
However, the following day I found 4k+ errors in the Error Log of the same two errors:
8: Undefined index: id
File: /Forum/Sources/PortalBlocks.php
Line: 2378

2: Illegal string offset 'group'
File: /Forum/Sources/PortalBlocks.php
Line: 2371
These two errors are from the Show Members in staff block (http://simpleportal.net/index.php?topic=14168.0) by Maizono, not from Grafitus New Staff Block.

Clean up the error log, remove Maizono block and re-install Grafitus one.
Title: Re: Staff List
Post by: ccbtimewiz on May 25, 2016, 10:16:54 PM
If desired, I will gladly assist you in adjusting my custom staff block for your particular need if you have difficulties with editing the PHP.
SimplePortal 2.3.8 © 2008-2024, SimplePortal