Leave a comment »

Integrating an RSS Feed Part 2

This is part two of the integrating RSS feeds article and includes a WordPress plugin.

Since we laid the ground work for integrating an RSS feed in the previous post I though we would move to the next logical step which is converting that code into a WordPress plugin.  Before you ask, there is no demo because this is not a WordPress blog but instead is running on a custom blogging platform that we have developed and named Diachronic. 

 

Rather than offer an exhaustive explanation of the plugin, I will describe its installation and use.  For those so inclined, there are plenty of comments in the source code that will help you understand how it all works. 

 

Step 1

Download the plugin.

 

Step 2

Unzip the plugin into your WordPress installation directory in the wp-content/plugins folder.

 

Step 3

Make sure the cache folder is still present inside of the SimplePie folder that was created.  If you are running Linux or some deriavitive do a 'chmod 777 cache' to ensure that the folder can be written to by the plugin.  If you don't do this, SimplePie will not be able to cache the RSS feeds and your site will be SLOW.  When all the other steps are complete, you can verify that caching is taking place by looking in the cache folder and seeing if you have one file for each feed that you are pulling.

 

Step 4

Log into your WordPress administration area and go to the Plugins menu.  You should see the RSS Pieces Feed Reader listed and you should see an option to activate the plugin.  Activate it now and you are one step closer to completion.

What you should see

 

Step 5

Go to the Presentation menu and select the Theme Editor option.  Click on the Sidebar link and it will let you edit the template that is used to display the sidebar.  In our example we went all the way to the bottom of the template and inserted the feed reader call above the last HTML div.  Click the Update File button to save the changes that were just made.

Our modified template

 

Step 6

Go to your home page and click the Refresh button.  You should see a news feed.  If you see an error message, you may have skipped step 3 which included doing a chmod to allow the plugin to write its cache files.

What ours looked like

 

Step 7

The source for the plugin contains a section of CSS that is used to style the posts.  If you don't like how the posts look, you can change them in the plugin.

 

Setting Options

This plugin has a number of options that can be set.  To send options you need to construct them in a way that the plugin can understand which is an option name followed by a colon and then the options value.

 

For example:

showdesc:1

This tells the feed reader to display the description that was pulled from the feed.

 

If you want to have more than one option, you separate them with commas like this:

showdesc:1, showdate: 0

This shows the description but suppresses the date field.

 

Option List

limit - Controls the number of posts that will be displayed from the RSS feed.  The default is 10.

feedtitle - This is the title to display at the top of the feeds.  The default is for the plugin to show the description that was in the RSS feed unless you override it by setting the feedtitle

showdesc - Displays the introductory text from the feed if it is set to something other than 0.  Setting it to 0 suppresses the description.  The default is 1.

showdate - If set to something other than 0, the date the article was posted will be displayed.  A 0 value means it will not be displayed.  The default is 1.

dateformat - This controls how a date is displayed.  For more information, visit the PHP website.  The default is 'j M Y'

 

Our example

< ?php feedReader('http://www.rsspieces.com/RSS2', 'limit:5, showdesc:1, showtitle:1, feedtitle:RSS Pieces'); ?>

s will pull the feeds from RSS Pieces showing only 5 posts and setting the feed title to 'RSS Pieces'

 

You could also fetch an ATOM feed from our site like this.

< ?php feedReader('http://www.rsspieces.com/ATOM', 'limit:5, showdesc:1, showtitle:1, feedtitle:RSS Pieces'); ?>

sp;

There you have it, a fairly functional and hopefully usable plugin for WordPress that will pull feeds from an RSS or ATOM source, cache them for performance reasons and has some level of customization.



http://www.rsspieces.com/000182
digg me Reddit newsvine del.icio.us Technorati
Posted on October 23, 2006 00:52:26 by Mary.McKnight

No comment yet...

Comment on this article

Your email address will not be displayed.

Your URL will be displayed.
Poor Excellent

Standard HTML is allowed in posts
Line breaks become <br />

Remember me

Allow users to contact you through a message form.
Captcha image.

Please enter the characters from the image above. (case insensitive)

This post has no feedback awaiting moderation...


real estate blogs

Like what you have been reading on this site?
Subscribe to our feed below.




Buy a Real Estate Blog

[Valid RSS 2.0] [Valid Atom 1.0] Valid XHTML 1.0 Transitional
All three RSS feeds validate - RSS, RSS 1.0, RSS 2.0
A note about validation
Call today to start a real estate blog. Toll free: 866-403-9626