|
Cookbook /
RssFeedDisplay-TalkSummary: Talk Page for RssFeedDisplay
Categories: RSS
Comments & Bugs2007-06-03 Current version contains some strange code for handling non-ASCII characters:
list($description,$title)=
preg_replace('/([^\x00-\x7f])/e','sprintf("&#%d;", ord($1))',array($description,$title));
If it breaks unicode characters you should remove these lines and add into your config.php (change utf-8 to your encoding): define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
Feb 10, 2007 rssdisplay was not showing the summaries from Atom feeds. To fix this, go through rssdisplay.php and replace all instances of "atom_content" with "summary". --Dominique Cimafranca July 19th 2006 Should Magpie be styling the RSS I just get a link in my Wiki when i add the markup (:RSS http://www.washingtonpost.com/wp-dyn/rss/politics/index.xml(approve links) long 5:) When you click on the link it brings you to the xml file. \ Thanks Feb 8th, 2006 The font size of the RSS Feed is very big compared to other sections in my website in IE6. How do I control the font size of the feed being display. I have found a work-around for this problem. I am doing the following to reduce the font size:
The
if ( $what == 'short' ) {
$line .= "[$link<BR>\n";
$line .= "<BR>";
}
if ( $what == 'long' ) {
$line .= "[$link<BR>\n";
$line .= $description . "<BR>";
$line .= "<BR>";
18 Nov 2005 This is great! I did have a difficulty. I found this feed at <http://www.fda.gov/bbs/topics/news/rssPress.xml>(approve links). It seems to generate faulty output with the script, though as far as I can tell it is a valid feed item. <item> <title>FDA Seeks Public Input on Renewal Process for Prescription Drug User Fee Act (PDUFA)</title> <description>FDA) will begin the public process toward reauthorization of the Prescription Drug User Fee Act (PDUFA), the law that allows the agency to help fund programs that have helped product developers get early and frequent advice about how to develop some of the last decades' most innovative and important medicines.</description> <pubDate>Thu, 10 Nov 2005 17:50:00 GMT</pubDate> <link>http://www.fda.gov/bbs/topics/news/2005/NEW01259.html</link> </item> Here is what the output looks like.
]] I am not sure what is happening, but it looks like an extra carriage return is being inserted before "]]". Perhaps the parentheses are doing this? Perhaps in Magpie? -- Mike I have no problems with this feed. Could be a magpie problem I use .61 BrBrBr Using rssdisplay.php,v 1.31 2005/10/18, the short display produces a dense column of output - no formatting of rows, no vertical space between lines. Since I don't want to add the space via my css, so on my installation I've modified lines 64-92 to include some <BR> tags and a • before each $link" $description=$description;
$link="<a class='urllink' href='$href'>$title</a><BR>";
$line .= "<h3 class='rss$what'>• $link</h3><BR>\n";
if ( $what == 'long' ) {
$line .= $description . "<br /><BR>\n";
}
-- Tegan Dowling (Thanks for a terrific recipe!)
Adding the dateYou can easily add the date to each item. Here is an example of a modification to the "modified script" (from above). First, change the include statement to this.
include_once("$FarmD/local/magpie/rss_fetch.inc");
include_once("$FarmD/local/magpie/rss_utils.inc");
Next, add the following to output.
# Original lines are below.
foreach ($items as $item)
{
$output .= '* %newwin% [['
. $item['link']
. "|"
. $item['title']
. "]]";
# Newly added lines are below.
# Reference: http://cz.php.net/manual/en/function.date.php
# Reference: http://www.cadenhead.org/workbench/entry/2004/06/17
$date = "";
$rss_2_date = $item['pubdate'];
$rss_1_date = $item['dc']['date'];
$rss_3_date = $item['prism']['publicationDate'];
$atom_date = $item['issued'];
if ($atom_date != "") $date = parse_w3cdtf($atom_date);
if ($rss_1_date != "") $date = parse_w3cdtf($rss_1_date);
if ($rss_2_date != "") $date = strtotime($rss_2_date);
if ($rss_3_date != "") $date = parse_w3cdtf($rss_3_date);
if ($date == '-1') {
if ($atom_date != "") $date = strtotime($atom_date);
if ($rss_1_date != "") $date = strtotime($rss_1_date);
if ($rss_3_date != "") $date = strtotime($rss_3_date);
}
if (($date != "") && ($date != '-1')) {
$secondsinaday = 60 * 60 * 24;
$dateformat = 'd M Y';
$today = time();
$yesterday = time() - $secondsinaday;
$datetoday = date($dateformat, $today);
$dateyesterday = date($dateformat, $yesterday);
$daterss = date($dateformat, $date);
if (($daterss == $datetoday) || ($daterss == $dateyesterday))
{
$color = 'red';
}
else {
$color = 'gray';
}
$output .= ' %' . $color . '% [-' . $daterss . '-]%%';
}
-- Mike 07 Dec 2005 Restricting output to recent feedsOf course, it is now easy to restrict output to recent feeds, just by adding a fourth parameter to the RSS directive. The parameter indicates how many days of feeds you want to display.
$dayoffset = 1;
$earliest = '';
if (isset($parameters[3])) {
$earliest = $today - ($parameters[3] + $dayoffset) * $secondsinaday;
}
You then just precede the output with a condition, like this.
if ((! isset($parameters[3])) || ($date >= $earliest) || ($date == '')) {
....
}
-- Mike 07 Dec 2005 Adding an imageYou can easily include the RSS images by adding these lines before the "foreach ($items as $item)" line in the modified script.
$images = $rss->image;
if (isset ($images['url']))
{
$output .= $images['url'] . "\n";
}
-- Mike 08 Dec 2005 Domain-specific targetsYou might like to specify a new window target only for links to other domains. Here is how.
$thishost = $_SERVER['HTTP_HOST'];
$parsed = parse_url($item['link']);
$target = (($thishost == $parsed['host']) ? 'same' : 'new');
if ((! isset($parameters[3])) || ($date >= $earliest) || ($date == '')) {
$output .= '* '
. '%'
. $target
. 'win% [['
. $item['link']
. "|"
. $item['title']
. "]]";
-- Mike 15 Dec 2005 Would someone think of an easy way to have something like an aggregator that tells which post have been read by the currently logged user. Could be that, for every post you read, you tick or press a button that saves in cache the title of the post and before reloading items from xml compares to this list. I'm just a php newby so if you think of anything to code this feature... --JoelMig? July 24th, 2006 - 22:20 |