Basically this is a last topics block, but you can target any section/sections you want with it. For example, I have a "for sale" category section with several boards in it. In the screenshot below, you can see I added all the boards in my "for sale" category to this block, so it would only display them.
To configure the boards that you want to display, go to the board on your website and look at what it displays in the address bar of your browser. It should display something like this...
http://yoursite.com/index.php?board=2.0
Where it says board=2.0, you take the number but drop everything after the decimal point. Take that and add it to the $show variable of the script, like this...
$show = "2";
Note: To add more then one board, you have to add a comma in between each number. Example: $show = "2,3,4,5";
I also left a few settings so you can change the title text color, the time and date of the post color, and the number of post to display.
<?php
global $smcFunc, $scripturl, $boardurl;
$show = "2,3,4,5"; // Show posts from these forums - seperate IDs with commas, eg: "2,8"
$limit = 5; // Amount of topics to display
$tzone = "" ; //timezone offset in seconds - 1 Hour = 3600 Seconds
$tcolor = "006633"; //Title test color
$dcolor = "CC9900"; //time and date color
echo'<table width="100%" border="1">
<tr><td width="40%"><center><b><font color="'.$tcolor.'">Topic Title</b></center></td>
<td width="20%"><center><b><font color="'.$tcolor.'">Topic Starter</font></b></center></td>
<td width="10%"><center><b><font color="'.$tcolor.'">Replies</font></b></center></td>
<td width="30%"><center><b><font color="'.$tcolor.'">Last Action</font></b></center></td>
</tr>';
$dbresult = $smcFunc['db_query']('', "
SELECT id_board, id_last_msg, id_first_msg, num_replies, id_topic, id_member_started, id_member_updated
FROM {db_prefix}topics
WHERE id_board IN ({$show})
ORDER BY id_last_msg DESC
LIMIT $limit ");
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$Replies=$row['num_replies'];
$lmess=$row['id_last_msg'];
$fmess=$row['id_first_msg'];
$topic=$row['id_topic'];
$fuserid=$row['id_member_started'];
$luserid=$row['id_member_updated'];
$boardid=$row['id_board'];
$tpresult = $smcFunc['db_query']('', "
SELECT id_board, name
FROM {db_prefix}boards
WHERE id_board = $boardid
LIMIT 1");
while ($tp = $smcFunc['db_fetch_assoc']($tpresult))
{
$bname=$tp["name"];
}
$fpresult = $smcFunc['db_query']('', "
SELECT poster_name, subject, id_msg
FROM {db_prefix}messages
WHERE id_msg = $fmess
LIMIT 1");
while ($fp = $smcFunc['db_fetch_assoc']($fpresult))
{
$starter=$fp["poster_name"];
$title=$fp["subject"];
}
$lpresult = $smcFunc['db_query']('', "
SELECT poster_name, subject, poster_time, id_msg
FROM {db_prefix}messages
WHERE id_msg = $lmess
LIMIT 1");
while ($lp = $smcFunc['db_fetch_assoc']($lpresult))
{
$lposter=$lp["poster_name"];
$ptime=$lp["poster_time"];
$ctime = ($ptime - $tzone);
$pubdate = date('M jS h:i A', ($ctime));
}
$fgrresult = $smcFunc['db_query']('', "
SELECT id_member, id_group, id_post_group
FROM {db_prefix}members
WHERE id_member = $fuserid
LIMIT 1");
while ($fgrp = $smcFunc['db_fetch_assoc']($fgrresult))
{
if ($fgrp['id_group'] == 0)
{
$fgroup=$fgrp['id_post_group'];
}
else
{
$fgroup=$fgrp['id_group'];
}
}
$lgrresult = $smcFunc['db_query']('', "
SELECT id_member, id_group, id_post_group
FROM {db_prefix}members
WHERE id_member = $luserid
LIMIT 1");
while ($lgrp = $smcFunc['db_fetch_assoc']($lgrresult))
{
if ($lgrp['id_group'] == 0)
{
$lgroup=$lgrp['id_post_group'];
}
else
{
$lgroup=$lgrp['id_group'];
}
}
$clresult = $smcFunc['db_query']('', '
SELECT id_group, online_color
FROM {db_prefix}membergroups');
while ($cl = $smcFunc['db_fetch_assoc']($clresult))
{
if ($cl['id_group'] == $fgroup)
{
$fcolor=$cl["online_color"];
}
if ($cl['id_group'] == $lgroup)
{
$lcolor=$cl["online_color"];
}
}
echo'<tr><td><img src="' . $boardurl .'/Themes/default/images/sp/arrow.png " /><a href="', $scripturl, '?topic=', $topic, '.0"> ', $title,'</a></td>
<td><center><a href="', $scripturl, '?action=profile;u=', $fuserid, '.0"> <font color="'.$fcolor.'">', $starter, '</font></a></center></td>
<td><center>', $Replies, '</center></td>
<td><font color="'.$dcolor.'"><b>', $pubdate, '</b></font><br><a href="', $scripturl, '?board=', $boardid, '.0"><b>In: </b>', $bname, '</a><br><b>By: </b><a href="', $scripturl, '?action=profile;u=', $luserid, '.0"><font color="'.$lcolor.'">', $lposter, '</font></a></td>
</tr>';
}
echo'</table>';
$smcFunc['db_free_result']($dbresult);
?>