SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Burke Knight on June 15, 2015, 04:57:43 PM

Title: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 04:57:43 PM
I'm making pages for each staff member.
I'd like to have a new staff block, that looks the same as the default, but allows me to change the links to the pages for each staff member.
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 15, 2015, 05:08:46 PM
Easy to edit, I just need to know what the new page URLs look like
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 05:26:47 PM
They are SP pages.
So would be: index.php?page=staffmembername
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 15, 2015, 05:45:42 PM
I'll need to know a bit more about the pages, for example if the staff member's name is my name, would it be SayakaMaizono without any spaces?

What about if I had my name as Sayaka-Maizono, would you omit the dash?
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 07:27:31 PM
I try not to use dashes in page ID's.
Like, my page would be burkeknight
I also tend to stay away from caps in page names. :)
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 15, 2015, 07:35:03 PM
Open ./Sources/PortalBlocks.php

Find:
Code: [Select]
$staff_list[$row['type'] . '-' . $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>',

Replace with:
Code: [Select]
$staff_list[$row['type'] . '-' . $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>',
'link' => '<a href="' . $scripturl . '?page="' . preg_replace('/\s*/', '', $smcFunc['strtolower']($row['real_name'])) . '">' . $row['real_name'] . '</a>',

This will automatically convert the names to lowercase and remove all the spaces. It might break when you get crafty with usernames however as this is a staff list, I don't think it will cause any problems.

Ideally you should use their IDs for the pages, like ?page=member1 and ?page=member54, but it doesn't look as nice.
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 07:58:55 PM
That breaks the block, it seems.
Also, like stated, I'm changing the names on them, a bit...

Quote
Ideally you should use their IDs for the pages, like ?page=member1 and ?page=member54, but it doesn't look as nice.
However, I wonder if can use their user name, instead?

Do note, I'm not using SMF, but using ElkArte.
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 15, 2015, 08:37:34 PM
Open ./Sources/PortalBlocks.php

Find:
Code: [Select]
$staff_list = array();
$colorids = array();

Replace with:
Code: [Select]
$staff_list = array();
$colorids = array();

$custom_staff = array(
array(
'id' => 1,
'name' => 'Sayaka Maizono',
'link' => $scripturl . '?page=maizono'
),
array(
'id' => 7,
'name' => 'Makoto Naegi',
'link' => $scripturl . '?page=naegi'
),
);

Find:
Code: [Select]
$staff_list[$row['type'] . '-' . $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'],
'type' => $row['type'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<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'] > 0 ? (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'])
),
);

Replace with:
Code: [Select]
$staff_list[$row['type'] . '-' . $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'],
'type' => $row['type'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<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'] > 0 ? (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'])
),
);

foreach ($custom_staff as $key => $member)
{
if ($member['id'] == $row['id_member'])
{
$staff_list[$row['type'] . '-' . $row['id_member']['link'] = '<a href="' . $member['link'] . '">' . $member['name'] . '</a>';
continue;
}
}

I made two entries in the array as an example so you can build it yourself, you just need to make a new array entry and then add 'id' (the user id of the member), their name, and then the link you want to make it.
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 08:49:58 PM
I kind of did something a little simpler, that would not edit a file, in case of SP update, since using it on ElkArte.
I used custom HTML block, and made own to resemble as much as can, but links to where I want.

However, it also is more hard coded, so any staff changes, I'll have to manually change it, as well. ;)

Thank you, though, for the help. :)
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 15, 2015, 08:56:57 PM
If you already did something simpler, why ask for a solution?
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 15, 2015, 09:21:34 PM
Well, like said, I kind of did something a little simpler, meaning, after I had done Reply #6.
If you think I'd do something, and then ask for help just to not use it, you are very mistaken.
However, it was due to editing the portal blocks page, instead of using a custom block to resemble, that I did it the way I did.

Like I stated, I'm running this on ElkArte, and we are still doing lots of work on the SimplePortal mod for it. That being said, file edits are not the best idea, as they are bound to get removed when doing updates.

Hence, the reason that people that post for custom blocks, have for them to be done as custom HTML or PHP blocks, and not file edits.
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 17, 2015, 01:32:52 AM
You want a block that will do this without any hard edits, so it works like a default block, but.. you want it for different forum software?

I'm not really following that, but I can add the fields in the database and adjust the staff block to "add" the features innate.

I'm not even sure if there is licensing problems with porting SP to other software...
Title: Re: Staff block where name links to pages
Post by: Burke Knight on June 17, 2015, 06:44:25 AM
You want a block that will do this without any hard edits, so it works like a default block, but.. you want it for different forum software?
I'm not even sure if there is licensing problems with porting SP to other software...

I wanted it in a custom block, to look like the regular staff block. That way, updates would not make it so would have to redo it.

I'm not really following that, but I can add the fields in the database and adjust the staff block to "add" the features innate.

There's no need, as I got it done, as custom HTML... Ok, I have to manually edit if any staff changes, but I rather doubt that would be hard to do.

I'm not even sure if there is licensing problems with porting SP to other software...

Before you start on lines like that, why don't you LOOK at what the license IS for SimplePortal.
Also, why not LOOK at the topic for SimplePortal at the ElkArte site: http://www.elkarte.net/community/index.php?topic=1399.0

Especially, look at Reply #3, and WHO posted that reply.
Title: Re: Staff block where name links to pages
Post by: ccbtimewiz on June 17, 2015, 06:49:23 PM
Oh, I know what that is now.

I wasn't aware of what ElkArte even was, I thought it was another forum software like IPB.
Title: Re: Staff block where name links to pages
Post by: LittleFang on September 10, 2018, 12:51:54 PM
This is a lovely mod! 

May I ask for a way to have the mod link to a user's custom forum section with their name?
SimplePortal 2.3.8 © 2008-2024, SimplePortal