OK, we may have to play around with this once we set it up (fix any errors, maybe make tweaks). But let's start out with this. Using a text only editor like NotePad, change the gfeedfetcher._sortarray function in the gfeedfetcher.js file to this (addition highlighted):
Code:
gfeedfetcher._sortarray=function(arr, sortstr){
var sortstr=(sortstr=="label")? "ddlabel" : sortstr //change "label" string (if entered) to "ddlabel" instead, for internal use
if (sortstr=="title" || sortstr=="ddlabel"){ //sort array by "title" or "ddlabel" property of RSS feed entries[]
arr.sort(function(a,b){
var fielda=a[sortstr].toLowerCase()
var fieldb=b[sortstr].toLowerCase()
return (fielda<fieldb)? -1 : (fielda>fieldb)? 1 : 0
})
}
else{ //else, sort by "publishedDate" property (using error handling, as "publishedDate" may not be a valid date str if an error has occured while getting feed
try{
arr.sort(function(a,b){return new Date(b.publishedDate)-new Date(a.publishedDate)})
}
catch(err){}
}
if(sortstr.indexOf('customlabel:') == 0){
sortstr = ',' + sortstr.substring(12) + ',';
arr.sort(function(a, b){
return sortstr.indexOf(',' + a.ddlabel + ',') - sortstr.indexOf(',' + b.ddlabel + ',');
});
}
}
Save and use that version of the script.
Now, where you do this when setting the filter for the feed:
Code:
instance.filterfeed(int, ["sortby"])
You can use a string like the one shown:
Code:
instance.filterfeed(int, 'customlabel:ESPN,SkySports,NFL,MLB,NHL,NBA,NCF,NCB,EPL,LFP,GER,SERIE A,UCL,UEL,MLS,GOLF')
It should sort the feeds the way you want them. Of course you must change instance to the actual instance and change int to an unquoted number representing the maximum number of items to display.
The browser cache may need to be cleared and/or the page refreshed to see changes.
If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks