RSS Feeds (blog) to HTML Websites

Joined
Mar 2, 2004
Messages
2,381
Location
Northern Colorado
I've searched and searched and feel like I am looking for the White House gate code or something! LOL I'm trying to write a basic HTML page which has an embedded section that it pulls the blog file on my website to this other page in order to display parts of the blog on it.

I've seen a few hits on javascripting this; some on reader programs, etc. But nothing with a simple, straight answer.

Does anyone know how this can be done? Again, what I want to do is make a spot on my page which can pull the last entry from my blog and post it onto a separate page.
 
Here's the way I do it:

1. Download this file: http://www.kritikal.com/scripts/lastRSS.phps
2. Save it to your public_html directory
3. Put this code into the page that you want to show just the 1 post

Code:
include 'lastRSS.php';
$ljrss = new lastRSS;

$ljrss->items_limit = 1;

if ($feed = $ljrss->get('http://LOCATION TO FEED')) {

	$title = "";
	$pubdate = "";
	$description = "";
	$body = "";

	foreach ($feed['items'] as $item) {
		$title = $item['title'];
		$pubdate = $item['pubDate'];
		$description = $item['description'];
		$body .= <<<BODY_HTML
			<table class="entry" cellpadding="0" cellspacing="0">
				<tr><td class="title">$title</td><td class="pubdate" align="right">$pubdate</td></tr>
				<tr><td class="desc" colspan="2">$description</td></tr>
			</table>

BODY_HTML;

Now, "$body" will have your rss html that you can just echo right out into the page. This code is directly from my ljrss script that I use so if you have any questions just let me know. You can also change the "$items_limit" variable to any number you want.
 
Back
Top