PDA

View Full Version : Display multiple RSS feeds based on a keyword using gAjax RSS v2



TennisWill
12-04-2012, 10:51 PM
1) Script Title: gAjax RSS Feeds Displayer v2.0 (hosted)

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

3) Describe problem:

Is there a way to display multiple feeds items based on a unique keyword?

An example for my tennis site; say I would like to create a page displaying only news items about 'John McEnroe'; using multiple RSS feeds. My keyword would be 'mcenroe'.

Is this possible using gAjax RSS Feeds Displayer v2.0?

Thank you for any help offered.

ddadmin
12-06-2012, 07:08 PM
Possibly, though it depends on what you mean exactly. Are you talking about filtering the entries so only ones with a certain keyword in their title or body show up, or do you mean searching and discovering RSS entries to show based on a keyword?

avril3
03-06-2013, 05:50 PM
Possibly, though it depends on what you mean exactly. Are you talking about filtering the entries so only ones with a certain keyword in their title or body show up, or do you mean searching and discovering RSS entries to show based on a keyword?

Would it be possible to filter and display entries based on category or pubDate?
Thanks

Beverleyh
03-06-2013, 06:40 PM
PHP5 has a native XML function that allows you to parse XML feeds as HTML, so if your web server run PHP5, you can use this script to filter by pubDate;

$feed_file = 'http://www.mywebsite.com/path/to/my-rss-feed.xml'; // URL of RSS
$cache_file = 'temp/my-rss-feed.rss'; // path to cache file
$cache_time = 3600*24; // 24 hours (set to 0 for no cache)
$date_filter = '2013-03-21'; // Date filter YYYY-MM-DD

$timedif = @(time() - filemtime($cache_file));
if (file_exists($cache_file) && $timedif < $cache_time) {
$string = file_get_contents($cache_file);
} else {
$string = file_get_contents($feed_file);
if ($f = @fopen($cache_file, 'w')) {
fwrite ($f, $string, strlen($string));
fclose($f);
}
}
$xml = simplexml_load_string($string);
foreach ($xml->channel->item as $val) {
$date = date('Y-m-d', strtotime($val->pubDate));
if ($date == $date_filter) {
echo '<p><b>'.$val->title.'</b><br/>'.$val->pubDate.' : '.$val->description.'</p>';
}
}(Adapted from http://www.finalwebsites.com/snippets.php?id=49 )