SimplePortal
Customization => Custom Coding => Topic started 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
global $txt, $scripturl, $settings, $context, $color_profile;
global $txt, $scripturl, $settings, $context, $color_profile;
global $smcFunc, $scripturl, $modSettings;
if ($display == 'compact')
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')
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
<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.
-
I believe this is not intended for SMF 1.1.13.
-
Oh, I forgot that say. It works only with SMF 2.0 for now.
-
Great custom!! thanks :D
-
in smf 2.0 rc3 does not work for me....
-
Update to SMF 2.0, the final version released.
-
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.
-
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.
-
Likely it works; I think no changes made to affect this code. And I don't try it right now.
-
I try it out a week ago. I really like to add this to the main forum.
-
Hello,
can i add this in news block?
Thanks
-
Hi there, how can i add this for recent post but not full.
-
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
-
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)
-
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)
-
Nobody care of simple portal please?
-
http://simpleportal.net/index.php?topic=9138.0
and be more patient next time...
-
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?
-
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.
-
I believe this is not intended for SMF 1.1.13.(http://simpleportal.net/Smileys/SimplePortal/smiley.gif) (http://web.teobit.ru)
-
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.
-
Nobody care of simple portal please?
-
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...
-
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