En una ocasión el master Santiago me hizo el favor de hacerme un código para hacer algo así, aunque ya no recuerdo exactamente cual era (se hicieron algunos cambios). Prueba con este:
Código:
<?php
if (!defined("IN_PORTAL")) {
die("<div style=\"border:1px solid #CC0000; padding:3px; margin:0; font-family:Tahoma; width:250px; font-size:12px;\"><strong>Error:</strong> This file cannot be viewed directly!</div>");
}
/********** CONFIG *********/
$threadspro = array(
'from_forums' => '2,4', // ID de los foros, separados por coma
'quantity' => 10, // Cuantos threads extraer
'chars' => 200, // Cuantos caracteres en el resumen
'after_cut' => '...' // String a agregar despues del corte
);
/********** END CONFIG *********/
// Get forums user cannot view
$unviewable = get_unviewable_forums();
if($unviewable)
{
$unviewwhere = " AND t.fid NOT IN ($unviewable)";
}
$threadlimit = 10;
$query = $db->query("
SELECT t.*, f.name AS forumname, t.subject AS threadsubject, u.username, u.usergroup, u.displaygroup, i.*, i.name AS iconname,
t.dateline AS threaddate, t.lastpost AS threadlastpost, p.message AS postcontent
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=t.icon)
LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
LEFT JOIN ".TABLE_PREFIX."posts p ON (t.firstpost=p.pid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (t.fid=f.fid)
WHERE t.visible = '1'
AND t.fid IN (" . $threadspro['from_forums'] . ")
$unviewwhere
GROUP BY t.tid
ORDER BY threaddate DESC
LIMIT 0, $threadlimit
");
while($threads = $db->fetch_array($query))
{
// Delete images
$postcontent = preg_replace('#\[img\](\r\n?|\n?)(https?://([^<>\"\']+?))\[/img\]#', '', $threads['postcontent']);
// Delete links with no anchor
$postcontent = preg_replace('#\[url\]([^\r\n\"<]+?)\[/url\]#', '', $postcontent);
// Delete any other bbcode (leaving the text inbetween intact)
$postcontent = preg_replace('#\[(.*?)\]#', '', $postcontent);
if(is_object($parser))
{
$postcontent = $parser->parse_html($postcontent);
}
if(strlen($postcontent) > $threadspro['chars'])
{
$postcontent = neat_trim($postcontent, $threadspro['chars'], $threadspro['after_cut']);
}
if($threads['icon'] > 0)
{
$icon = "<img src=\"{$threads['path']}\" alt=\"{$threads['iconname']}\" title=\"{$threads['iconname']}\" />";
}
else
{
$icon = " ";
}
if(strlen($threads['threadsubject']) > "40")
{
$threadsthreadsubject = my_substr($threads['threadsubject'],0,40)."...";
}
else
{
$threadsthreadsubject = $threads['threadsubject'];
}
if(strlen($threads['forumname']) > "20")
{
$threadsforumname = my_substr($threads['forumname'],0,20)."...";
}
else
{
$threadsforumname = $threads['forumname'];
}
$threadlink = get_thread_link($threads['tid']);
$forumlink = get_forum_link($threads['fid']);
$forumname = $threads['forumname'];
$replies = my_number_format($threads['replies']);
$views = my_number_format($threads['views']);
$lastpostdate = my_date($mybb->settings['dateformat'], $threads['threadlastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $threads['threadlastpost']);
$lastposter = format_name($threads['username'], $threads['usergroup'], $threads['displaygroup']);
$lastposter = build_profile_link($lastposter, $threads['lastposteruid']);
/*********** EDIT HERE? **********/
/* {$postcontent} = POST CONTENT */
/*********** EDIT HERE? **********/
$last_thread_modified .= "<tr>
<td class=\"trow1\" align=\"center\" height=\"24\">$icon</td>
<td class=\"trow2\"><a href=\"$threadlink\" title=\"$threads[threadsubject]\">$threadsthreadsubject</a><br /><small>{$postcontent}</small></td>
<td class=\"trow1\" align=\"center\"><a href=\"{$forumlink}\">{$forumname}</a></td>
<td class=\"trow1\"><span class=\"smalltext\">$lastpostdate $lastposttime<br />by $lastposter</span></td>
</tr>";
}
if(!$last_thread_modified){ $last_thread_modified = "<tr><td class=\"trow1\" colspan=\"5\">{$lang->no_thread}</td></tr>"; }
echo "<table border=\"0\" cellspacing=\"".$theme['borderwidth']."\" cellpadding=\"".$theme['tablespace']."\" class=\"tborder\">
<tr>
<td class=\"thead\" colspan=\"6\"><div class=\"expcolimage\"><img src=\"{$theme['imgdir']}/{$expcolimage}\" id=\"block_{$result_blocks['id']}_img\" class=\"expander\" alt=\"{$expaltext}\" title=\"{$expaltext}\" /></div><strong>{$lang->latest_threads}</strong></td>
</tr>
<tr>
<td class=\"tcat\" width=\"5%\" height=\"24\"> </td>
<td class=\"tcat\" width=\"50%\"><span class=\"smalltext\"><strong>{$lang->latest_threads_thread}</strong></span></td>
<td class=\"tcat\" width=\"10%\" align=\"center\"><span class=\"smalltext\"><strong>Foro</strong></span></td>
<td class=\"tcat\" width=\"25%\" align=\"center\"><span class=\"smalltext\"><strong>{$lang->latest_threads_lastpost}</strong></span></td>
</tr>
<tbody style=\"{$expdisplay}\" id=\"block_{$result_blocks['id']}_e\">
{$last_thread_modified}
</tbody>
</table>";
// http://www.justin-cook.com/wp/2006/06/27/php-trim-a-string-without-cutting-any-words/
function neat_trim($str, $n, $delim='...') {
$len = strlen($str);
if ($len > $n) {
preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches);
return rtrim($matches[1]) . $delim;
}
else {
return $str;
}
}
?>
Me parece que no te va a mostrar los iconos del foro, sino el icono del mensaje, en caso que el autor haya colocado alguno, pero si fuere el caso, debe ser fácil de cambiar.