I want to find a lightweight script (can be included in a non-vb page) that can pull the first post out of x number of threads from a specific forum (or two) then can count the number of additional posts (for a Comments (12)) type thing.
I don't want to use a CMS / Portal whatever as they are bloated and tend to use VB styles.
I have searched and searched but cant find anything.
Thanks in advance
Edit: I looked into vbExternal, it is pretty close to what I want. The only problem is it operates from inside the vb folder. So it can only be used to include from one forum. I want similar functionality but I also would like for different news to be pulled from a different forum for say subdomains or addon domains. for instance
www.site1.com pulls news from forum 2 while hosted.site1.com pulles from forum 5 and
www.site2.com pulls from forum 12
Thanks
Well. I looked some more, checked out VbExternal again. waited for a response. And came up with this.
It works, but i'm not an expert coder at all. A lot of it is ripped from vbExternal I was not impressed with the limitations of it. So please someone, anyone read over the code and tell me if there are any obvious flaws or any improvements.
PHP Code:
<?php
// Vb news test. Note: a lot of this is reworked vbexternal code.
// Actually all of it is :P Thanks to Zero Tolerance.
// ob_start();
// I saw this in vbExternal, thought it looked cool
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT', 'news');
$news_number = '5'; // Amount of news to pull
$news_forum = '3'; // From which forum?
// Change over to vb's directory so we can include global.php
$old_dir = getcwd(); // used later maybe.
chdir('path/to/forum');
require_once('./global.php');
// Check to make sure the chdir took.
if( !file_exists('./includes/config.php'))
{
echo "includes/config.php does not exist. Cannot continue.";
exit;
}
function RunError($message = ""){
echo "<font size='1' face='verdana'>There was an error while processing vBExternal:<br />{$message}</font>";
exit;
}
// Include some shit I think is important :P
require_once('./includes/class_core.php');
require_once('./includes/config.php');
require_once('./includes/class_bbcode.php');
// Test to make sure a forum was set.
if (!$news_forum) {
RunError("No Specified Forum to pull news from, Edit the script you bum");
}
// The actual Query WOOT!
$pulled_news = $db->query("
select t.*,p.pagetext
from ".TABLE_PREFIX."thread t
left join ".TABLE_PREFIX."post p on(p.postid=t.firstpostid)
where t.forumid = $news_forum
order by dateline desc
limit 0,$news_number");
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while($News = $db->fetch_array($pulled_news)){
$thread_id = $News['threadid'];
$thread_title = $News['title'];
$post_userid = $News['postuserid'];
$post_username = $News['postusername'];
$post = $bbcode_parser->parse(unhtmlspecialchars($News['pagetext']), $f);
$comments = vb_number_format($News['replycount']);
echo "<a href=\"http://www.mysite/forum/showthread.php?p=$thread_id\">$thread_title</a>";
echo "Posted by <a href=\"http://www.mysite.com/forum/member.php?u=$post_userid\">$post_username</a>";
echo "$post";
echo "Comments: <a href=\"http://www.mysite.com/forum/showthread.php?p=$thread_id\">$comments</a>";
}
chdir($old_dir);
?>