2010-01-07, 11:20 PM
I'm not too savvy at php but using some resources from here and a bit of time I've got a great working version to integrate your main site with recent forum posts.
Although fully editable, this script will display:
Subject
Subject Creator
Replies
Views
Last Poster
a working example can be found here: http://www.backofthelandingnet.co.uk
Instructions:
1. Put this php script at the beginning of the page you want to display the recent posts on line 1 (before the HEAD tags)
2. edit the chdir to the path to your forum
3. Insert the code below where you want recent posts to be displayed
4. Change the amount of recent posts you want to have displayed
That's it!
Although fully editable, this script will display:
Subject
Subject Creator
Replies
Views
Last Poster
a working example can be found here: http://www.backofthelandingnet.co.uk
Instructions:
1. Put this php script at the beginning of the page you want to display the recent posts on line 1 (before the HEAD tags)
<?php
chdir("pathtoforums/"); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
?>
2. edit the chdir to the path to your forum
3. Insert the code below where you want recent posts to be displayed
<?php
$query = mysql_query("
SELECT t.*, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid=t.uid)
WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC
LIMIT 0, 6" // Change the last digit to how many recent post you want to be shown
);
$list = '';
while($fetch = mysql_fetch_array($query))
{
$list .= "<strong><a href=\"forums/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
$poster = "<a href=\"forums/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
$list .= "Created by: {$poster}<br />";
$list .= "<i>" .$fetch['replies']. " Replies</i>";
$list .= "<i> , " .$fetch['views']. " Views</i><br />";
$list .= " (<i>Last post by: " .$fetch['lastposter']. "</i>)<br /><hr width=\"50\"><br />";
}
//output
echo $list;
?>
4. Change the amount of recent posts you want to have displayed
That's it!