SimplePortal

Customization => Custom Coding => Topic started by: knight0323 on October 06, 2009, 05:56:06 PM

Title: Recent Topics Help
Post by: knight0323 on October 06, 2009, 05:56:06 PM
Code: [Select]
global $txt, $scripturl, $settings, $context, $color_profile;

$boards = null;
$limit = 5;
$type = 'ssi_recentTopics';

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

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

foreach ($items as $item)
echo '
<tr>
<td class="sp_recent_icon sp_center">
', $item['new'] ? sp_embed_image('topic') : '<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>',
'</td>
<td class="sp_recent_subject">
<a href="', $item['href'], '">', $item['subject'], '</a><br />[', $item['board']['link'], ']
</td>
<td class="sp_recent_info sp_right">
', $item['poster']['link'], '<br />', $item['time'], '
</td>
</tr>';

echo '
</table>';

I pulled this directly from the Recent Topics block code and started doing some modifications. All I really want to accomplish is some display changes and formatting but I didn't want to edit the actual portal php files so I want to do this through the PHP Block.

I started coding it and I hit Preview every now and then to see if it was working. That works fine. Unfortunately when I click Add Block I get the following error:

Quote
Syntax error in block code. Please check the code.

Can anyone here point me in the right direction?

Thanks!
Title: Re: Recent Topics Help
Post by: Nathaniel on October 06, 2009, 07:20:10 PM
You're using SMF 2 RC1.2 with SP 2.3 right?

I don't get any syntax errors for that code when I try to add it on a clean copy of SMF 2 RC1.2 with SP 2.3.
SimplePortal 2.3.8 © 2008-2024, SimplePortal