SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Nori on November 02, 2009, 09:35:16 AM

Title: Preview of Recent Topics
Post by: Nori on November 02, 2009, 09:35:16 AM
I'm not sure if I missed something, but is there a way to show more of the posts in recent topics? I'd like to display a teaser for it or something like that....
Title: Re: Preview of Recent Topics
Post by: Nathaniel on November 02, 2009, 05:45:57 PM
This isn't possible with the inbuilt blocks, but its quite easy to modify the inbuilt blocks.

Try the code below (in a Custom PHP block):
Code: [Select]
global $txt, $scripturl, $settings, $context, $color_profile;

$include_boards = array();
$limit = 5;

// Let's restrict the query boys (and girls)
$query_where = '
m.id_msg >= {int:min_message_id}
' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND m.approved = {int:is_approved}' : '');

$query_where_params = array(
'is_approved' => 1,
'include_boards' => $include_boards === null ? '' : $include_boards,
'min_message_id' => $modSettings['maxMsgID'] - 25 * min($limit, 5),
);

// Past to this simpleton of a function...
$items = ssi_queryPosts($query_where, $query_where_params, $limit, 'm.id_msg DESC', 'array', true);

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'];
}
}

echo '
<table class="sp_fullwidth">';

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
', sp_embed_image(empty($parameters['type']) ? 'post' : 'topic'), '
</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>
<tr>
<td colspan="3">', $item['body'], '</td>
</tr>';

echo '
</table>';

If you want to change the styling, then the html code around the '$item['body']' variable can be changed.
Title: Re: Preview of Recent Topics
Post by: Nori on November 03, 2009, 04:28:54 PM
Awesome! It works great. Thankyou!
SimplePortal 2.3.8 © 2008-2024, SimplePortal