MyBB Community Forums

Full Version: Help - I need to paypal someone to put Forum Excerpts on homepage of static site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I built a static website in the following format

http://www.mydomain.com

I installed mybb in a sub-directory

http://www.mydomain.com/forum

I would like to put the latest 4 or 5 forum post (with thread title and little excerpts and readmore link) on my homepage of my main website.

I read through some of the threads and this one got me real close

http://community.mybb.com/thread-62787-page-5.html

I sort of got it working but there is a conflict with a WordPress install I have in another sub directory on same site. I'm thinking its something to do with .htaccess and shouldn't be that hard to fix for one of you masters.

I have a call for wordpress blog excerpts on line #1 of my staic site code but I cant have the myBB call too its either or but not both at same time or white screen of death.

I got to work on another part of the site for now and was hoping I could paypal someone some cash to help me out here.

PM me if you can help me out and tell me what you did

help a bro out?

any help would be greatly appreciated
$20 or $30 bucks?
save the $20 and use and RSS reader plugin for wordpress and simply link to the syndication page of your MyBB install
By coincidence I was just working on implementing something like this in a new version of a website that I'm building, so here is my suggestion:

Page itself (if it's a html file you'll need to rename it to .php as otherwise this doesn't work)
<?php
	$rss = new DOMDocument();
	//location rss feed (add '?fid=11,16' or alike if you only want certain forums to show in the RSS feed)
	$rss->load('http://mydomain.com/forum/syndication.php');
	$feed = array();
	//get feed data
	foreach ($rss->getElementsByTagName('item') as $node) {
		$item = array ( 
			'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
			'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
			'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
			'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
			);
		array_push($feed, $item);
	}
	//feed limit
	$limit = 5;
	//print feed data
	for($x=0;$x<$limit;$x++) {
		$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
		$link = $feed[$x]['link'];
		$description = $feed[$x]['desc'];
		$date = date('l F d, Y', strtotime($feed[$x]['date']));
		echo '<p class="feedItemHead"><span class="feedItemTitle"><a href="'.$link.'" title="'.$title.'">'.$title.'</a></span><br />';
		echo '<span class="feedItemDate">Posted on '.$date.'</span></p>';
		echo '<p class="feedItemDescription">'.$description.'</p>';
		// adds horizontal line between feed items
		if ($x < $limit-1) {
		echo '<hr size="1" width="80%" />';
		}
	}
?>


Add this to your CSS to customize the individual elements
p.feedItemHead {
	
}

p.feedItemDescription {

}

span.feedItemTitle {
	font-size:18px;
	font-weight:bold;
}

span.feedItemDate {
	float:right;
	font-style:italic;
	font-size:12px;
}

As this is based on the RSS feed, a user should only be able to see what he/she would otherwise see in your forum's RSS feed. However, you might want to add/remove some <br />, <hr /> code to make it fit better with your website design. Also, keep in mind that if your 'feed limit' ($limit) is higher than the amount of visible threads (f.e. if nothing is visible for guests), the remaining feed items will only show the date 'Posted on Thursday January 01, 1970' while the other areas stay empty.

P.S. This is just a slightly adjusted version as can be found on http://bavotasan.com/2010/display-rss-feed-with-php/, so credits go to him.
thanks for reply guys. I'll look into it. I see some PHP in there and I'm betting I'm going to have the same white screen conflict with wordpress. (white screen of death)

I really don't mind paying a little cash to help me get this all setup
PMed you
On a static page the code I mentioned above shouldn't conflict as it uses the MyBB RSS output to get the information (the information generated by http://mydomain.com/forum/syndication.php ).

The link you tried changes the working directory of the PHP from your main page to the MyBB forum (chdir) and from there acquires the needed information using MyBB internal PHP variables. My guess is that due to this method, a conflict might appear if you also want wordpress excerpts as well using PHP, as it thinks it's still in your forum directory (you would probably need to execute another chdir again going back to your main page to make that the working directory again).