OK, what I've done now, is use the PHP from this thread to show news posts on my homepage, and then made a Joomla mod with it. You can see it here:
http://www.generalemu.be. Now, I'm not sure how to fix the parsing of the bbcode to have it show the quotes and lists correctly, as they aren't being parsed. Also, is there any way to have attachments show on the homepage (even thumbnails if it's attached images)? And wondering how I can insert a line to separate the posts that are being shown. Any help with this would be greatly appreciated. Here's the PHP I have so far, which has most of it working.
<?php
$forumpath = "./forums/"; // Path to your forums root directory (with trailing slash)
$fid = "5"; // The forum ID to pull the annoucements from
$limit = "30"; // The amount of annoucements to show
require $forumpath."inc/config.php";
function bb_code(&$string){
$pattern = array(
//[ul]
'#\[list\](.*?)\[\/list\]#si',
//[*]
'#\[\*\](.*?)(\r\n|\r|\n|<br>|<br />|<br/>)#si',
//[url]
'#\[url\](.*?)\[\/(url)\]#si',
//[url=XXX]
'#\[url=("|"|\'|)(.*?)\\1\](.*?)\[\/url\]#si',
//[i],[u]
'#\[u\](.*?)\[/u\]#si',
'#\[i\](.*?)\[/i\]#si',
//[b]
'#\[b\](.*?)\[/b\]#si',
//[img]
'#\[img\](.*?)\[\/img\]#si',
// font size
'#\[size=("|"|\'|)([0-9\+\-]+)\\1\](.*?)\[\/size\]#si', '#(\r|\n|\r\n)#si');
$replacement = array(
//ul
"\t\t<ul>$1</ul>\r\n",
//li
"\t\t\t<li>$1</li>\r\n",
//a
'<a href="$1">$1</a>',
//a
'<a href="$2">$3</a>',
//i, u
'<u>$1</u>',
'<em>$1</em>',
//b
'<strong>$1</strong>',
//img
'<img src="$1" alt="User Posted Image" />',
//size
'<font size="\2">\3</font>', "<br />");
$string = preg_replace ($pattern, $replacement, stripslashes($string) ); $string = str_replace ('<br /><br />', "</p>\r\n\t\t<p>", $string);
}
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.dateline,t.replies,p.message,u.avatar FROM ".$config['table_prefix']."threads t LEFT JOIN ".$config['table_prefix']."posts p ON (t.tid = p.tid) LEFT JOIN ".$config['table_prefix']."users u ON (t.uid = u.uid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC LIMIT 0, ".$limit."") or die(mysql_error());
while ($news = mysql_fetch_array ($query)){
$date = gmdate ("jS F Y", $news['dateline']);
$time = gmdate ("h:i A", $news['dateline']);
//Parse BBCode
bb_code($news['message']);
if($news['replies'] == "1"){
$replytext = "reply";
} else {
$replytext = "replies";
}
if($news['avatar'] != ""){
if(substr($news['avatar'], 0, 7) != "http://")
{
$url = $forumpath;
}
$avatarbit = "<img style='float:left; margin:10px;'src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" />\r\n\t\t";
} else {
$avatarbit = "";
}
echo "\t<div class=\"news\">\r\n\t\t";
echo "<div class='details'>(<a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['replies']." ".$replytext." </a>) | Posted by <a href=\"".$forumpath."member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."</div>\r\n\t\t";
echo "<h2>".$news['subject']."</h2>\r\n\t\t";
echo $avatarbit."<p>".$news['message']."</p>\r\n\t\t<div style=\"clear:both;\"></div>\r\n\t";
echo "</div>\r\n";
}
?>