• HTML/CSS
  • jQuery
  • PHP
  • JS
  • AJAX
  • MySQL
  • Res
  • XSLT
  • Contact Us
  • HTML/CSS
    • Game Development →
      • HTML5 Game Development - Lesson 1
      • HTML5 Game Development - Lesson 2
      • HTML5 Game Development - Lesson 3
      • HTML5 Game Development - Lesson 4
      • HTML5 Game Development - Lesson 5
      • HTML5 Game Development - Lesson 6
      • HTML5 Game Development - Lesson 7
    • Menus →
      • CSS3 multilevel menu with transition and animation
      • Marble Style CSS3 Navigation Menu
      • Toggle CSS3 Bottom Navigation Bar
      • Accordian like CSS3 Onclick Vertical Navigation
      • Multilevel CSS3 Metal Navigation with icons
      • Click-action CSS3 Dropdown Menu with jQuery
      • Click action Multi-level CSS3 Dropdown Menu
      • CSS3 Animated Menu
      • CSS3/jQuery crossbrowser Drop-down menu with tabs
      • CSS3 Drop sliding list Menu #6
      • CSS3 Slideout Menu #5
      • CSS3 Dropdown Menu #4
      • CSS3 Dropdown Menu #3
      • CSS3 Dropdown Menu #2
      • Cool CSS3 Dropdown Menu
    • Templates →
      • Robo Splash Page Layout
      • 'Mono' HTML5 CSS3 Single Page Layout
      • HTML5/CSS3 single page layout - Art theme
      • Attractive HTML CSS Anime Theme Website Layout
      • HTML CSS website layout #4 - Gray theme
      • Dark and clean HTML CSS website layout
      • HTML5&CSS3 single page layout - Rock portal
      • E-Store HTML5 CSS3 Single Page Layout
      • Under Water Themed HTML5 & CSS3 single page Layout
      • HTML5 & CSS3 Single Page Web Layout
    • HTML5 tutorials →
      • HTML5 Canvas Slideshow
      • HTML5 canvas - Custom brush #2 (Bubble brush)
      • HTML5 canvas - Custom brush (BezierCurveBrush)
      • HTML5 Face Builder
      • Pure HTML5 file upload
      • HTML5 image crop tool
      • HTML5 animation - patterns with loops
      • HTML5 3D circle text with shadows
      • HTML5 canvas pixelate effect
      • Animated Moving Clouds using HTML5
      • Animated Fireplace in HTML5
      • 3D Animated Box HTML5 WebGL Photo Slideshow
      • Your Own Paint Program
      • Image Zoomer in HTML5 Canvas
      • Photo Array in WebGL
      • HTML5 Canvas Image Color Picker
      • HTML5 Image Effects App - Adding Horizontal Flip
      • Keyboard Sensitive 3D Twisted Images in WebGl
      • Animated 3D WebGL Demonstration
      • HTML5 Image Effects App - Adding Noise and Invert
      • HTML5 Canvas Image Effects App - Adding Blur
      • Attractive Presentation with HTML5
      • HTML5 Canvas App for Online Image Enhancements
      • Water Ripple effect using HTML5 canvas
      • Animated 3D canvas object in HTML5
    • CSS3 tutorials →
      • CSS3 Image Hover Effects
      • CSS3 Modal Popups
      • Isometric interactive interior guide
      • Analog Clock with Pure CSS3
      • CSS3 Optical Illusions
      • CSS3 Animated Photo Slider
      • CSS3 Christmas Tree with Snow
      • How to Create a Pure CSS3 Slideshow
      • CSS3 Drop Caps
      • Pure CSS3 Slider
      • Fantastic Animated Buttons using CSS3
      • How to Create a Pure CSS3 Animated Photo Gallery
      • Toggle CSS3 Bottom Navigation Bar
      • How to Generate Runtime Multi-columns with CSS3
      • Multiple backgrounds and Animation with CSS3
  • jQuery
    • Photo album with jQuery Fotorama
    • Photo album with jQuery Chop Slider
    • Cool Background Image Sliding effect with jQuery
    • jQuery Templates - Usage Practice
    • Photo Album with Galleriffic jQuery plugin
    • Fantastic Photo Album with TN3
    • Ajaxy Photo Gallery (jQuery) with Custom Images Sets
    • Rotating Slider with Easing Effects in jQuery
    • Animated jQuery Progressbar Plugin
    • Nice CSS3 Lightbox Gallery
    • Photo Album with Highslide
    • Using Flux Slider jQuery plugin
    • Ajaxy Chained Selects
    • Modern jQuery Pagination for Content
    • Your own jQuery Slider Plugin
    • Attractive Photo Gallery using SmartGallery
    • Animated Photo Gallery using jQuery (Slider Kit)
  • PHP
    • Powerful Chat System - Lesson 3
    • Powerful Chat System - Lesson 2
    • Powerful Chat System
    • Access Control with Bit Masks
    • Own XML/JSON/HTML API with PHP
    • Your Own Ajax Poll System
    • Diary style PHP Guestbook
    • Smooth Curve Graphs with PHP and GD
    • Your Own Commenting System from Scratch
    • Autocomplete with PHP, jQuery, MySQL and XML
    • Your Own 5 Stars Voting System
    • How to use Memcache with PHP
    • How to install APC on Linux
    • How to Use APC Caching with PHP
    • Watermark processing on images using PHP and GD
    • ID3 Tags Reader with PHP
    • Advance Level Login system with Logic captcha
    • Protection and Methodologies of Security Vulnerabilities
    • How to Resize images on Server Side
    • How to Protect any Site from Spam using Akismet
    • Phar - PHP archiving practice
  • JS
    • Form Validation with Javascript and PHP
    • Fullscreen Javascript Slide navigation
    • Photo Scrambler grid in javascript
    • Photo Slideshow (zoom fading) effect
    • Custom scrollbars - cross-browser solution
    • Flare Lens Effect
    • Own RSS Reader Using Google Feed API
    • Cross-browser Wave Effects
    • Cross-browser Supported Image Skew effect
  • Res
    • ← Infographic
      • The Evolution of Languages
    • ← jQuery plugin roundups
      • December 2011
      • November 2011
      • 10 fresh jQuery Tutorials
      • October 2011
      • September 2011
      • 10 fresh Ajax related jQuery plugins
      • August 2011
      • 10 Oven Fresh jQuery Plugins for UI
      • 10 Most creative jQuery plugins for tables
      • 10 Most Creative jQuery Navigation Plugins
      • 10 fresh jQuery plugins for working with forms and UI
      • 10 superb jQuery plugins for working with images
    • ← HTML5 stuff
      • HTML5 and Games
      • 10 Fresh HTML5 Tutorials
      • Fresh impressing WebGL demonstrations
      • Most impressing HTML5 with WebGL demonstrations
      • 10 Fresh & Impressive HTML5 Canvas (and WebGL) Examples
      • 10 Exceptional Examples of HTML5 Canvas and Applications
    • ← Mobile
      • How to start developing own applications for Android
      • 10 Fresh Android tutorials
      • 10 Attractive Tutorials for Developing iPhone Applications
      • 10 Attractive android tutorials for developers
      • 10 Fresh iPad Apps for Web Designers & Developers
      • 10 Fresh Android Apps for Web Designers & Developers
      • 10 Fresh iPhone Apps for Web Designers & Developers
      • Top 10 iPhone apps for working with graphics
    • 12 Unique Navigation Menu Designs For Your Inspiration
    • 15 Unique and Creative Layouts 2011
    • 12 Beautifully Creative Flash Websites of 2011
    • Fresh collection of Original Captchas
  • XSLT
    • Animated forums using XSLT and Ajaxy
    • Multilevel Menu using XSLT
    • Delicious bookmarks using XSLT transformation
    • XPath visually
    • Tags cloud using XSLT transformation
    • Youtube videos using XSLT transformation
  • Contact Us
KEEP IN TOUCH

Import RSS Feeds using jFeed (jQuery)

Jun01
2010
29 Comments Written by admin

Import RSS FeedImport RSS Feeds from any rss enabled site using jFeed (jQuery)

This simple tutorial will show u how to Import rss feeds of any site into your own custom area/block of site. It can be used as news import from yahoo, bbc etc. As we know, RSS feeds usually using to transfer some news to readers. Today I will tell you about RSS feeds and teach you how to make own RSS aggregator. So you will able to display different RSS feeds at your website with nice design.

Here is a sample:

Live Demo
Download in package

Ok, download the example files and lets start coding !


Step 1. HTML

As usual, we start with the HTML.

This is our main page code (with 2 RSS blocks). Pay heed to RSSAggrCont elements. At its params. ‘rssnum’ mean how many rss elements will display at page. ‘rss_url’ – RSS url. Hope you will able to easy change these params.

templates/rss_page.html

<link href="templates/css/styles.css" rel="stylesheet" type="text/css" />

<script language="javascript" type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.jfeed.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.aRSSFeed.js"></script>

<div class="RSSAggrCont" rssnum="5" rss_url="http://rss.news.yahoo.com/rss/topstories">
    <div class="loading_rss">
        <img alt="Loading..." src="templates/images/loading.gif" />
    </div>
</div>

<div class="RSSAggrCont" rssnum="5" rss_url="http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml">
    <div class="loading_rss">
        <img alt="Loading..." src="templates/images/loading.gif" />
    </div>
</div>

<script language="javascript" type="text/javascript">
$(document).ready( function() {
    $('div.RSSAggrCont').aRSSFeed();
} );
</script>

Step 2. CSS

Here are used CSS styles.

templates/css/styles.css

.RSSAggrCont {
    border:1px solid #AAA;
    -moz-box-shadow:0 0 10px #ccc;
    -webkit-box-shadow: 0 0 10px #ccc;
    width:500px;
    padding:10px;
    background:#f3f3f3;
    margin:15px;
    float:left;
}

/* RSS Feeds */
.rss_item_wrapper {
    padding-bottom: 8px;
}
.rss_item_wrapper:last-child {
    padding-bottom: 0px;
}
.rss_item_header {
    font-size:12px;
    font-weight:bold;
    padding-bottom:0px;
}
.rss_item_header a,
.rss_item_header a:link,
.rss_item_header a:visited,
.rss_item_header a:hover,
.rss_item_header a:active {
    font-size:12px;
    font-weight:bold;
    color:#33c;
}
.rss_item_info {
    color:#999;
    font-size:9px;
}
.rss_item_desc {
    text-align:justify;
    font-size: 11px;
}
.rss_read_more {
    background-color:#EDEDED;
    font-size:11px;
    font-weight:normal;
    height:30px;
    line-height:30px;
    vertical-align: middle;
    margin-top:2px;
    padding:0 9px;
    text-align:left;
    text-decoration:none;
    text-transform:capitalize;
}
.loading_rss {
    text-align:center;
    width:89px;
    height:64px;
    background-image:url(../images/loading_bg.png);
    z-index: 10;
    margin: 10px auto;
}
.loading_rss img {
    margin-top: 16px;
}
.loading_rss div {
    width:89px;
    height:64px;
    background-image:url(../images/loading.gif);
    background-position:center center;
    background-repeat:no-repeat;
}

Step 3. JS

Here are few necessary JS files to our project.

js/jquery.aRSSFeed.js

// jQuery plugin - Simple RSS Aggregator
(function($){
    $.fn.aRSSFeed = function() {
        return this.each( function(){
            var $Cont = $(this);
            var iMaxNum = parseInt($Cont.attr( 'rssnum' ) || 0);
            var sFeedURL = $Cont.attr('rss_url');

            if (sFeedURL == undefined)
                return false;

            $.getFeed ({
                url: 'get_rss_feed.php?url=' + escape(sFeedURL),
                success: function(feed) {
                    if (feed != undefined && feed.items) {
                        var sCode =
                            '<div class="rss_feed_wrapper">';
                        var iCount = 0;
                        for (var iItemId = 0; iItemId < feed.items.length; iItemId ++) {
                            var item = feed.items[iItemId];
                            var sDate;
                            var a;
                            var oDate

                            if (null != (a = item.updated.match(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z/)))
                                oDate = new Date(a[1], a[2]-1, a[3], a[4], a[5], a[6], 0);
                            else
                                oDate = new Date(item.updated);
                            sDate = oDate.toLocaleString();

                            sCode +=
                                '<div class="rss_item_wrapper">' +
                                    '<div class="rss_item_header">' +
                                        '<a href="' + item.link + '" target="_blank">' + item.title + '</a>' +
                                    '</div>' +
                                    '<div class="rss_item_info">' +
                                        '<span><img src="templates/images/clock.png" /> ' + sDate + '</span>' +
                                    '</div>' +
                                    '<div class="rss_item_desc">' + item.description + '</div>' +
                                '</div>';

                            iCount ++;
                            if (iCount == iMaxNum) break;
                        }

                        sCode +=
                            '</div>' +
                            '<div class="rss_read_more">' +
                                '<img class="bot_icon_left" src="templates/images/more.png" />' +
                                '<a href="' + feed.link + '" target="_blank" class="rss_read_more_link">' + feed.title + '</a>' +
                            '</div>' +
                            '<div class="clear_both"></div>';

                        $Cont.html(sCode);
                    }
                }
            } );
        } );
    };
})(jQuery);

js/jquery-1.4.2.min.js and js/jquery.jfeed.js

This is common files – jQuery library with addon. No need to give full code of that file here. It always available as a download package

Step 4. PHP

I hope that most code will easy for your understanding – each function have normal name and commented.

Ok, here are all used PHP files:

index.php

<?php

require_once('templates/rss_page.html');

?>

get_rss_feed.php

<?php

$sUrl = (isset($_GET['url']) && $_GET['url'] != '') ? $_GET['url'] : 'http://www.boonex.com/unity/extensions/latest/?rss=1';

header( 'Content-Type: text/xml' );
readfile($sUrl);

?>

Step 5. Images

Also we need several images for our project:

    clock icon
    loading icon
    loading background icon
    more icon

View Live Demo
download in package

Conclusion

Today I told you how to create own RSS aggregator using jQuery library – jFeed. You can use this material to create own scripts into your startups. Good luck!

About: admin:
I am web developer with huge experience (in web languages and even in system languages). Also I am the founder of current website (and several another). I like to write blogs about web development/design. Feel free to Follow us on Twitter: tweetmeme_screen_name='AramisGC';
If you Enjoyed our article don't forget to Share the love with your friends.
    Tweet
   
   
Written by: admin on June 1, 2010.
Last revised by: admin
on July 26, 2010.

Related Stuff You Will Love!

  1. Importing multiple RSS feeds – using newsWidget (jQuery)
    Importing multiple RSS feeds – using newsWidget (jQuery)
  2. Cropping images in runtime using Jcrop (jQuery)
    Cropping images in runtime using Jcrop (jQuery)
  3. Easily Animate Web Buttons/Objects using jQuery
    Easily Animate Web Buttons/Objects using jQuery
  4. Creating jQuery Templates – Usage Practice
    Creating jQuery Templates – Usage Practice
Posted in HTML/CSS, JavaScript, jQuery - Tagged jFeed, jQuery, news feed, rss feed
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« How to Easily Make AJAX Style PHP Chat Application
» How to Easily Make Your own RSS Feed

28 Comments

  1. nishad's Gravatarnishad
    October 27, 2010 at 9:10 pm | Permalink

    how can i control the content display form the feed .. whn i try this with feedburner feed link its shows the full content.. i need post title + short intro about the post..

  2. Grunwalski's GravatarGrunwalski
    November 10, 2010 at 11:52 pm | Permalink

    heyho…well done. thx :)

    I would like to import multiple rss Feeds and ORDERthem by date in one list. Do you have a suggestion where to look? there is alot of stuff, using webservices to combine them. but i want to collect all RSS Feeds, relevant to the students of my course…and i want them to be realtime. so they need to be imported on client-side.

  3. admin's Gravataradmin
    November 11, 2010 at 11:29 am | Permalink

    So just follow sample 2, it collect all elements and sorting its by date

  4. nomnom's Gravatarnomnom
    January 6, 2011 at 4:45 am | Permalink

    I use this script and it’s working great in localhost, but when I host that in some server, the page always stay in loading state. I’ve tried to host in different servers but it stay the same. Are there any settings i’m missing?

    thanks

  5. admin's Gravataradmin
    January 6, 2011 at 5:00 am | Permalink

    I advice you to track all possible JS errors. As example – install Firebug plugin to your Firefox, and look for errors. Possible your custom page have some errors, or, hosting unable to connect to external source of RSS feed

  6. nomnom's Gravatarnomnom
    January 7, 2011 at 4:49 am | Permalink

    thanks for the reply
    I host your sample code to test the result, and it seems that my hosting cannot connect to external source of RSS. Is there probably any settings on the server we need? I’ve tried changing the permission but the page still do not load.

  7. admin's Gravataradmin
    January 8, 2011 at 4:06 am | Permalink

    Hi, try to check server variable ‘allow_url_fopen’, try to set to 1 (ON)
    possible reading
    http://bugs.php.net/bug.php?id=28497
    will help

  8. Rakesh's GravatarRakesh
    January 21, 2011 at 1:03 pm | Permalink

    Hi,

    Can I do this using classic ASP instead of PHP ? I want to implement the same functionality for an ASP website ? any thoughts ??

  9. admin's Gravataradmin
    January 26, 2011 at 8:39 am | Permalink

    Yes, sure, just repeat what I doing in PHP in your ASP, this is small and easy code.
    You will need just return RSS feed text in your custom ASP file (instead my get_rss_feed.php)

  10. Nat's GravatarNat
    February 15, 2011 at 3:20 pm | Permalink

    Hi, this is really great post, but i have some problem.
    I am a beginner in a web development, and the problem is same: When i try the demo, everything is Ok, but downloading the source, it doesn’t work.
    Maybe that should insert into localhost, or it is not necessary?
    I really need your help, because i want to make similar page in my website.
    Thank you

  11. admin's Gravataradmin
    February 19, 2011 at 5:09 pm | Permalink

    Yes, sure, try this at localhost, this sample should work, just because I made it (when prepared this post) at localhost too :)

  12. stock charts's Gravatarstock charts
    February 25, 2011 at 12:20 pm | Permalink

    Hi, great post. I’ve been looking at improving the rss feed on my site. Now I just need to adapt it to asp.net. :)

  13. Mike's GravatarMike
    March 10, 2011 at 6:41 am | Permalink

    Hi Admin,

    Great post on this RSS feed. I’ve tried everything but can’t seem to get it to show up inside of another .php file. No problem if I post it alone. See examples below:

    By itself (working)
    http://www.ebaytales.com/feed/

    Embedded inside a php file (not working):
    http://www.ebaytales.com/searchS.php?type=2&cid=24

    Just says “Loading..” I know it’s trying because the footer comes through but the feed doesn’t. Viewed the source code and it looks the same on both pages. Not sure what’s going on.

    Note: I’ve already set allow_url_fopen = on in the php.ini. Also I I get a java error in IE.

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
    Timestamp: Thu, 10 Mar 2011 06:39:17 UTC

    Message: Object expected
    Line: 266
    Char: 1
    Code: 0
    URI: http://www.ebaytales.com/searchS.php?type=2&cid=43

    266: $(document).ready( function() {

    Hope that helps you find the bug.
    Thanks in advance.

    Mike

  14. admin's Gravataradmin
    March 20, 2011 at 5:32 am | Permalink

    Just make sure that you have only one instance of jquery at page (not several calls).

  15. lep's Gravatarlep
    June 9, 2011 at 11:39 am | Permalink

    Beware: This won’t work in browsers with Javascript turned off.

    Maybe modify the code a bit, so w/ Javascript turned off, it just shows the images?

  16. admin's Gravataradmin
    June 15, 2011 at 8:55 am | Permalink

    2 lep
    Of course don`t will work, even jQuery library not will work in case if we will disable JS in browser :)
    If you want to display some image/warning in case when JS disabled – you can just drop this image in layout.
    And, remove that image in JS. So if JS enabled – your image will removed when page will loaded.

  17. Terry's GravatarTerry
    June 19, 2011 at 6:24 pm | Permalink

    See how it just tries to load the feed but never does
    why?
    thanks

  18. admin's Gravataradmin
    June 21, 2011 at 2:59 pm | Permalink

    2 Terry,
    Are demo don`t working for you?

  19. Iris's GravatarIris
    July 3, 2011 at 10:58 am | Permalink

    It won`t work in my site. See for yourself: http://infodrumtest.zymichost.com/?p=33 . Please help me figure this out. Firebug said there`s an error somewhere, but I`m not familiar with jQuery and can`t fix it myself. Thanks a ton.

  20. admin's Gravataradmin
    August 2, 2011 at 2:19 pm | Permalink

    2 Iris
    Maybe you faced with problem of second jQuery instance?
    try to disable jquery of our sample. Possible you already had jQuery in your project?

  21. Faghan's GravatarFaghan
    November 1, 2011 at 7:03 pm | Permalink

    It doesn’t work for me either. On none of my browsers, maybe because I updated them all recently and there were bunch of modifications.

    It doesn’t replace the gif part with the actual feed. Your demo, however, is working. It is just when I am trying to load it from my website or locally that it does not work

  22. Cassie's GravatarCassie
    November 1, 2011 at 9:52 pm | Permalink

    Great RSS feeder, just what we were looking for. Just one question – I am not able to decipher how to edit the image size. Is that possible?

  23. Mani's GravatarMani
    November 9, 2011 at 3:03 pm | Permalink

    Hi Admin,

    Hi, great post

    How can i increase the large content in my page?

  24. admin's Gravataradmin
    November 21, 2011 at 7:49 am | Permalink

    Hello Mani,

    What do you mean? Which large content?

  25. admin's Gravataradmin
    November 21, 2011 at 7:57 am | Permalink

    Hello Cassie,
    Images is provided by RSS providers. If you will provide bigger images in your RSS – you will have bigger images too

  26. Billy's GravatarBilly
    November 27, 2011 at 9:41 pm | Permalink

    Great post! Thanks for the information!

    I was wondering if it would be possible to have multiple sources read out of a single feed…

  27. admin's Gravataradmin
    December 8, 2011 at 4:57 pm | Permalink

    Hello Billy,

    Why not, but in this case you have to create another way to pass multiple source URLs to get_rss_feed.php.
    And after, read multiple URLs (readfile) and mix results into single XML file.

  28. admin's Gravataradmin
    December 8, 2011 at 5:02 pm | Permalink

    Hello Faghan,

    I can suggest you to test it in firefox browser. And please – activate Fiebug plugin. It seems that you have some another JS error at this page.

  1. RSS feed – using jFeed (jQuery) to aggregate RSS | Neorack Tutorials on June 1, 2010 at 7:16 am

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

CAPTCHA Image
Refresh Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Popular Tutorials

  • How to create easy pagination with jQuery
  • Animated jQuery Progressbar Plugin
  • Pure HTML5 file upload
  • Creating a HTML5 & CSS3 Single Page Web Layout
  • HTML5 Game Development – Lesson 6
  • How to Create Animated Photo Gallery using jQuery (Slider Kit)
  • Developing Your First HTML5 Game – Lesson 1
  • How to Easily Make a PHP Chat Application

Tags

3d AJAX android animated animation app application applications apps canvas captcha chat system coding creating css css3 developers effect effects flash fresh gallery how-to html html5 image images iphone javascript jQuery layout menu navigation new photo PHP plugin plugins slideshow system tutorial tutorials webgl website xslt

Recent Tutorials

  • Infographic: The Evolution of Languages
  • 12 Unique Navigation Menu Designs For Your Inspiration
  • Form Validation with Javascript and PHP
  • 10 fresh jQuery plugins (january 2012)
  • Powerful Chat System – Lesson 3
  • Invoicera offer results
  • CSS3 Image Hover Effects
  • HTML5 Canvas Slideshow

Friends

  • X-Musics

Tutorials for Web Developers Copyright © 2009-2011 Script tutorials · All rights reserved