Welcome to WebmasterWorld Guest from 188.8.131.52
I can successfully pull every entry of my feed into my target page, but I need to greatly limit that. I only want the title and first paragraph of the newest entry to be displayed. If this is now a PHP question, let me know and I'll ask for help in the PHP forum. Thanks.
You just need to get the feed generated the way you want. You could use something like Google's FeedBurner. They have a feature called Summary Burner that does this: "Offer a short summary of your hyperlink-free content and direct your subscribers to your Web site for the rest of the story."
Here's what's happening so far: I create a RSS feed using Blogger. Blogger's feed gets pulled into FeedBurner and summarized. FeedBurner's feed gets pulled into my homepage.
There are only a couple things left to be tweaked. I need only the newest post to be displayed from the FeedBurner feed and I need the page to look for feed updates with every refresh. Thoughts?
joined:Mar 29, 2009
1) Have your Blogger feed settings set to publish short summaries of your posts (default is full).
2) Download MagpieRSS (I used version 0.72) to your server and place its files in a directory called "magpierss" at the same directory level of the PHP page that will display your feed.
3) Copy/paste the code below into the PHP page that will display your feed:
$rss = fetch_rss( 'YourAbsoluteFeedURL/atom.xml' );
/* Uncomment the following line to see the object and array data returned. Good to see which other information has been processed by magpierss */
// echo "<pre>"; print_r($rss); echo "</pre>";
//display latest blog content:
$blog_title = $rss->channel[title];
$item = $rss->items;
$title = $item['title'];
$content = $item['summary'];
echo "<div class='latest_news' style='background-color: #ffffff;'>\n";
echo "<p><strong>$title</strong><br />$content...</p>\n";
echo "<p style='margin-bottom: 0px; text-align: right; padding-right: 50px;'><a href='#'>Read more >></a>\n";
4) Change the echo portions of the code above to display your feed with whatever HTML you want.
5) Open "magpierss/rss_fetch.inc" and find line #350.
6) Change the "60*60" to equal how frequently (in seconds - default 1 hour) you want the feed to look for new posts. I set mine to 1*60 (1 minute).
Note) If you want to display other information (author, timestamp, etc.), un-comment the echo line in the code above to see what information is available.
That's it! I hope my time spent figuring all this out can be a benefit to someone else.
[edited by: j2trumpet at 9:43 pm (utc) on April 11, 2009]