Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1182
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Add avatar to birtdays

Started by MarkoKg, May 01, 2013, 08:06:04 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

MarkoKg

Hello there.

Is there any way to add member avatar instead of member username in calendar block?
I tried few edits in PortalBlocks.php but i didn't manage to do this.

I belive that proper line to edit would be this one:
<li>', sp_embed_image('birthday'), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';
Any help please?

I tried to add $member['avatar']['image'] there, but it doesn't work though...

[SiNaN]

Sources/Subs-Calendar.php

Code (Find) Select
}
$smcFunc['db_free_result']($result);

// Set is_last, so the themes know when to stop placing separators.


Code (Replace) Select

$member_ids[] = $row['id_member'];
}
$smcFunc['db_free_result']($result);

if (!empty($member_ids))
{
$request = $smcFunc['db_query']('','
SELECT m.id_member, m.avatar, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
WHERE m.id_member IN ({array_int:members})
LIMIT {int:limit}',
array(
'members' => $member_ids,
'limit' => count($member_ids),
)
);
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 = '';
}

$avatars[$row['id_member']] = 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'])
);
}
$smcFunc['db_free_result']($request);

if (!empty($avatars))
{
foreach ($bday as $set_key => $list)
{
foreach ($list as $member_key => $data)
{
if (isset($avatars[$data['id']]))
$bday[$set_key][$member_key]['avatar'] = $avatars[$data['id']];
}
}
}
}

// Set is_last, so the themes know when to stop placing separators.


Sources/PortalBlocks.php

Code (Find) Select
<li class="sp_list_indent">', sp_embed_image('birthday'), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';

Code (Replace) Select
<li class="sp_list_indent">', sp_embed_image('birthday'), (!empty($member['avatar']['href']) ? ' <img src="' . $member['avatar']['href'] . '" alt="' . $member['name'] . '" width="20" /></a>' : ''), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';

Note that there might be two instances of the second "find" code, one for calendar block and the other for calendar information block. Make sure you replace the correct one. (they appear in the order I mentioned above in the file)

Also you can change 20 in the last code block to change the size of the avatar.
And slowly, you come to realize... It's all as it should be...

MarkoKg

Wow, that was quick, thanks man! :)

Works like a charm! :)

[SiNaN]

It's nowhere near when I was still young. You're welcome. ;)
And slowly, you come to realize... It's all as it should be...