SimplePortal

Customization => Custom Coding => Topic started by: shayneb on October 16, 2014, 12:15:08 AM

Title: Recent *Posts* Block with Icons
Post by: shayneb on October 16, 2014, 12:15:08 AM
I would like to have a recent *posts* block that shows every single recent post and has the icon of the original topic (as opposed to the icon of the reply).

I found some things that are *very* close to what I would like here: http://simpleportal.net/index.php?topic=13215.0 (http://simpleportal.net/index.php?topic=13215.0)
but none of those show the correct posts, from what I can tell. I think they were made to show recent *topics.*

When compared to the built-in Recent Posts block, quite a few posts are missing. They may still be a good jumping-off point for someone a little more educated in coding than I.

I would prefer it look exactly like the built-in Recent *Posts* block, but with the icons of the appropriate messages/topics instead of the "default" icon.

Thank you all!!
Title: Re: Recent *Posts* Block with Icons
Post by: shayneb on October 17, 2014, 06:23:44 PM
I also found this code, which displays all the information I want, but has the icon of the REPLY to the post, whereas I would prefer the icon of the ORIGINAL "topic" in the post (the first message). It is the icon that best represents what the post is really about.

Code: [Select]
global $txt, $scripturl, $settings, $context, $color_profile;

$block_parameters = array(
'boards' => 'boards',
'limit' => 'int',
'type' => 'select',
'display' => 'select',
);

if ($return_parameters)
return $block_parameters;

$boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 10;
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
$display = 'full';

$items = $type($limit, null, $boards, 'array');

if (empty($items))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
else
$items[count($items) - 1]['is_last'] = true;

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['poster']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}

if ($display == 'compact')
{
foreach ($items as $key => $item)
echo '
<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
}
elseif ($display == 'full')
{
echo '
<table class="sp_fullwidth">';

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
<img src="'.$settings['images_url']. '/post/'.$item['poster']['icon'].'.gif" alt="" />
</td>
<td class="sp_recent_subject">
<a href="', $item['href'], '">', $item['subject'], '</a>
', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
</td>
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
</tr>';

echo '
</table>';
}
SimplePortal 2.3.8 © 2008-2024, SimplePortal