PHP Code:
<?
error_reporting(7);
$templatesused='header,newsbit,shownews,headerbit,newsheaders';
//What is the ID of your News forum?
$newsforums = 48;
//How many news items should be displayed?
$newsitems = 10;
//Path to your forums directory (leave out trailing slash), i recomend using [url]http://www.domain.com/forumpath[/url]
$forumspath = "/forums";
require('./global.php');
$newsquery = "SELECT thread.*, post.*";
$newsquery .= " FROM thread,post";
$newsquery .= " WHERE post.threadid=thread.threadid";
$newsquery .= " AND thread.forumid=$newsforums";
$newsquery .= " GROUP BY thread.threadid";
$newsquery .= " ORDER BY thread.dateline DESC";
$newsquery .= " LIMIT $newsitems";
$headlinequery = "SELECT thread.*";
$headlinequery .= " FROM thread";
$headlinequery .= " WHERE forumid = $newsforums";
$headlinequery .= " ORDER BY threadid";
$headlinequery .= " DESC LIMIT $newsitems";
if ($action == "headlines") {$query = $headlinequery;} else {$query = $newsquery;}
$passthruquery=$DB_site->query($query);
while ($newsarray=$DB_site->fetch_array($passthruquery)) {
//Get date in their timezone
$dateposted = vbdate("jS F Y, H:i",$newsarray[dateline]);
//If they select anything but 'headlines' as their action, assume they want news.
if ($action != "headlines") {
//You may remove this, and replace any reference to $commenttext in the templates to Coments, or use replacment variables
//Make it plural if there is more than one comment
if ($newsarray[replycount]==1) {
$commenttext = "Comment";
}
else {
$commenttext = "Comments";
}
//Process the thread, and make it parse vBcode, and stuff
$cookedthread=bbcodeparse2($newsarray[pagetext],"1","1","1","1");
//Call the template 'newsbit' for each news entry it finds in the database
eval("\$newsbits .= \"".gettemplate("newsbit")."\";");
}
//They want headlines, so they get headlines
if ($action == "headlines") {
eval("\$newsbits .= \"".gettemplate("headlinebit")."\";");
}
}
eval("dooutput(\"".gettemplate("shownews")."\");");
?>