SimplePortal

Customization => Custom Coding => Topic started by: grafitus on April 01, 2011, 06:57:34 AM

Title: Add Avatar to Recent Topics/Posts Block
Post by: grafitus on April 01, 2011, 06:57:34 AM
This tip allows you to add members' avatars to Recent Topics/Posts block. You could look at how it looks from below:

(http://simpleportal.net/index.php?action=dlattach;topic=8607.0;attach=5025;image)

./Sources/PortalBlocks.php
Code: (Find) [Select]
global $txt, $scripturl, $settings, $context, $color_profile;
Code: (Replace) [Select]
global $txt, $scripturl, $settings, $context, $color_profile;
global $smcFunc, $scripturl, $modSettings;

Code: (Find) [Select]
if ($display == 'compact')
Code: (Replace) [Select]
if ($display == 'full')
{
$members = array();
foreach ($items as $item)
$members[] = $item['poster']['id'];

$request = $smcFunc['db_query']('', '
SELECT m.id_member, m.avatar, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
INNER JOIN {db_prefix}attachments AS a ON (m.id_member = a.id_member)
WHERE m.id_member IN ({array_int:member_ids})',
array(
'member_ids' => $members,
)
);
$avatar_profile = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$avatar_profile[$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($avatar_profile))
foreach ($items as $k => $p)
if (!empty($avatar_profile[$p['poster']['id']]))
$items[$k]['poster']['avatar'] = $avatar_profile[$p['poster']['id']];
}

if ($display == 'compact')

Code: (Find) [Select]
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
Code: (Replace) [Select]
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
<td class="sp_top_poster sp_center">', !empty($item['poster']['avatar']['href']) ? '
<img src="' . $item['poster']['avatar']['href'] . '" alt="' . $item['poster']['avatar']['name'] . '" width="40" />' : '', '
</td>

It works only in "Full" display type.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: Devil jimmy on April 01, 2011, 11:45:05 AM
I believe this is not intended for SMF 1.1.13.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: grafitus on April 01, 2011, 02:36:12 PM
Oh, I forgot that say. It works only with SMF 2.0 for now.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: tartenpoint on April 22, 2011, 08:48:46 AM
Great custom!! thanks  :D
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: visualuser on September 12, 2011, 05:37:29 PM
in smf 2.0 rc3 does not work for me....
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: ccbtimewiz on September 12, 2011, 08:22:14 PM
Update to SMF 2.0, the final version released.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: visualuser on September 13, 2011, 06:04:05 AM
it is a great step that for me, so i prefer at the moment not to make such changes....
forum must be close for some days....
I woll plan it later.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: Shadow Queen on September 14, 2011, 01:13:13 PM
Does this code work for the Gold Version of SMF?

Because I was trying this out on my test site and it didn't show up at all. I would like to add this to my main site.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: grafitus on September 17, 2011, 06:46:23 PM
Likely it works; I think no changes made to affect this code. And I don't try it right now.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: Shadow Queen on September 21, 2011, 11:57:23 AM
I try it out a week ago. I really like to add this to the main forum.

Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: iobit on October 03, 2011, 03:45:35 AM
Hello,
can i add  this in news block?

Thanks
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: kenng on October 29, 2011, 04:37:20 AM
Hi there, how can i add this for recent post but not full.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: BaghdadGhost on January 08, 2012, 03:14:49 AM
I have

smf v2.0.2

sp 2.3.4

I did the above changes and added the block but still the same as before.


thanks
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: nontanun on March 08, 2012, 02:55:14 AM
sorry about my English
and i need help.
---------------------
before
(http://uppic.zubza.com/images/1331193743816_sp1.jpg)

after
(http://uppic.zubza.com/images/1331193705921_sp2.jpg)

Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: senyor35 on May 17, 2014, 05:10:54 PM
Hello. How can I add the avatars to recent posts right sidebar block please? Example:

(http://sv102.piclect.com/af71c0051/o/14/05/17/sidebar1.jpg)
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: senyor35 on May 18, 2014, 08:34:03 AM
Nobody care of simple portal please?
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: phantomm on May 18, 2014, 10:21:35 AM
http://simpleportal.net/index.php?topic=9138.0

and be more patient next time...
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: senyor35 on May 18, 2014, 05:29:15 PM
Hello. Thank you for reply and this is good but I don't want topic description in block. Only show topic title and avatar.. Possible please?
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: AngelinaBelle on May 19, 2014, 11:42:27 AM
senyor35 -- please see http://simpleportal.net/index.php?topic=8607.msg45912#msg45912
By description perhaps you mean the board the topic was posted in?  You could certainly change the block to leave that part out.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: OLzenizin on May 23, 2014, 02:35:27 AM
I believe this is not intended for SMF 1.1.13.(http://simpleportal.net/Smileys/SimplePortal/smiley.gif) (http://web.teobit.ru)
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: andy on June 06, 2014, 11:05:47 PM
Have you tried this custom block code?

Recent Topics/Posts with Post Preview
http://simpleportal.net/index.php?topic=9138.0

I use it on my site (link in signature). You can set the preview to zero and if you dont want the date and poster details maybe you can edit that to stop it outputting that data. Test it and ask for help on that thread if needed.
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: aktiwIN on January 14, 2015, 03:27:05 AM
Nobody care of simple portal please?
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: ♦ Ninja ZX-10RR ♦ on January 14, 2015, 07:42:16 AM
Nobody care of simple portal please?
You just registered and post something like this that makes no sense... I'd like to know what's wrong with you...
Title: Re: Add Avatar to Recent Topics/Posts Block
Post by: Dzonny on March 01, 2015, 12:30:22 PM
Hey there,

Just tried this, but I can't figure out why it works only for custom added avatars. It shows custom uploaded avatars, but If I choose avatar from gallery it just won't show.

Screenshot attached, and yes I triple-checked that third member has an avatar chosen.

EDIT: Tried on one more forum and got the same problem.
I think that the problem might be with the AvatarOnBoard mod that I'm using:
http://custom.simplemachines.org/mods/index.php?action=parse;mod=1103;attach=87114;smf_version=2.0
SimplePortal 2.3.7 © 2008-2021, SimplePortal