Article

Diary of A Webmaster Part 2 - Create a Content Feed

Page: 1 2 3

What makes our content feed dynamic?

Many things. The fact that we have complete control over the feed.php script on our server means that we may change anything we like in it (e.g. to include a sponsor's ad). Any sites that already use our content feed won't have to do a thing to get the updated version, because it's retrieved from our server every time it's displayed on their site.

Also, whenever we add a new item to our articles table, it will appear at the top of the content feed. Let's try adding one now. Using the MySQL console application, enter this query:

insert into articles values(0, 'MySQL Version 4 Released', 'Today,    
MysQL AB have released MySQL version 4. It comes packed with a number    
of new features including transactions and faster    
query execution plans');

Return to your browser and hit the refresh button; notice the new entry in the list of news stories:

667CF2

It's just as easy to remove items from our content feed using the MySQL delete command:

delete from articles where articleId < 3;

This would remove those articles whose articeId was less than three, thus leaving two news headlines in our feed:

667CF3

So, as you can see, using the <script src="..."> method to include the JavaScript generated by our feed.php script in other sites' pages ensures that any new records we add will automatically be visible in the content feed when it's displayed.

Conclusion

Take the sample content feed described throughout this article and modify it to match the look and feel of your site. You'll also need to modify the MySQL queries to extract the right fields from your database.

Once you've customised the script for your needs, tell everyone about it: your ezine subscribers, friends, other Webmasters, etc. You'll be amazed by how many of them will agree to post it on their site because it's so simple to do.

Remember, all that anyone needs to do to get your content feed is include HTML code similar to the following (with the URL of your feed.php file, of course) in any page of their site:

<script language="JavaScript" type="text/javascript"  
src="http://www.jb-news.com/feed.php"></script>

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: