View Full Version : sort rss by date (gAjax RSS Feeds Displayer)

08-07-2010, 08:12 PM
1) Script Title: gAjax RSS Feeds Displayer

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm

3) Describe problem:

i seem to be having a problem with the sorting of feeds using the gAjax RSS Feeds Displayer script. actually, i am using both a feed scroller and just a static display - the scroller works fine, but the static display only shows the earliest post and not the most recent.

basically, i am using the static display so that page content can be updated using an rss feed. it doesn't/shouldn't scroll or change in this case. i haven't done anything to the original code at all, other than to specify that one result display (and is sorted by date as in the original code).

i have been patient and done updates over the space of a few days, as i am aware that the google api dates time to refresh, but my original post is still displaying. as i say, the other ticker/scroller workes fine, and the results appear one-by-one in the correct order - so i'm sure the sort functions are working properly.

any ideas?

08-08-2010, 05:27 PM

In the example on the demo page, there is a typo:

cssfeed.filterfeed(10, "title") //Show 10 entries, sort by date

That should be date. If you are using title that could be it.

In the gfeedfetcher.js script, it prunes the feed items using the Google API before it sorts them. This (in the case of only one item) would of course mean that it takes the first item.

I think it's probably this second issue. I'm imagining that as items (posts in this case) are added to your feed, they're added at the bottom. That would make the earliest item/post always the first. If you can change how items are added to the feed, adding them to the top instead, that should take care of it.

Other than that, you would have to specify the number of items as equal to or greater than the total number, then prune it to one later, after the sort, via a bit of custom code and/or css.

08-08-2010, 10:26 PM

i'll give your second option a try. it's not a problem sorting the order of the post at the moment, but i'm not sure how some of the rss editors might sort the items in the xml file - i'm just thinking about how to make it possible for a non-programmer to add content without a big headache (wishful thinking).

08-09-2010, 12:15 AM
I'm thinking that most feeds work this way - newest at the top. Otherwise, much of what the Google API does wouldn't make sense. Even putting the Google API aside for a moment - say you're subscribing to a feed with your browser (many do this now), what do you want to see at the top of the list, the oldest or the newest item?