Hi,
I've recently upgraded to the latest version of efiction (3.4.2) and have decided to use RSS feeds to announce new work posted in the efiction section of my site in a dedicated forum for such announcements. However, I'm experiencing a few problems with the RSS feed.
I've made a couple of minor adjustments to the RSS code already and have the feeds coming to my forum like this at the moment:
Topic Title: [Story Title] by [Author Name]
Body Text: [Story Rating] [Story Summary][link]
That's fine, but what I really want is for it to look like this:
Topic Title: [Story Title], [Chapter Number (if there are 2 or more chapters)] by [Author Name]
Body Text: [Story Category] [Story Rating][Story Summary]
[link]
In other words, I would like the story chapter number to appear in the title of the announcement if there are two or more chapters in the story, I would like the category (genre) to appear in the body text of the announcement and I would like the summary to be moved to a line or two below the category and rating in the announcement text.
Also, at present I'm not getting new announcements if a story is updated. I am assuming this is because IPB is not creating a new announcement if the text is the same as an existing announcement, so adding the chapter field might fix that, but if not (or if there is some other solution) I would be grateful.
This is the text of the current RSS file:
<?php
// ----------------------------------------------------------------------
// Copyright (c) 2007 by Tammy Keefer
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
define("_BASEDIR", "");
include_once("includes/dbfunctions.php");
include_once("config.php");
$settingsresults = dbquery("SELECT sitename, url, siteemail, slogan, language, tableprefix, dateformat FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
$settings = dbassoc($settingsresults);
foreach($settings as $var => $val) {
$$var = $val;
}
define("TABLEPREFIX", $tableprefix);
define("SITEKEY", $sitekey);
include_once("includes/queries.php");
if(file_exists("languages/{$language}.php")) include("languages/{$language}.php");
else include("languages/en.php");
ob_start ("ob_gzhandler");
function xmlentities ( $string )
{
return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&' , '"', ''' , '<' , '>' ), $string );
}
$ratlist = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_ratings");
while($rate = dbassoc($ratlist)) {
$ratings[$rate['rid']] = $rate['rating'];
}
$rss="<?xml version="1.0" encoding=""._CHARSET.""?>n";
$rss.="<rss version="2.0">n";
$rss.="<channel>n";
$rss.="<copyright>Copyright ".date("Y")."</copyright>n";
$rss.="<lastBuildDate>".date("r")."</lastBuildDate>n";
$rss.="<description>".xmlentities($slogan)."</description>n";
$rss.="<link>$url</link>n";
$rss.="<title>".xmlentities( $sitename)."</title>n";
$rss.="<managingEditor>$siteemail</managingEditor>n";
$rss.="<webMaster>$siteemail</webMaster>n";
$rss.="<language>$language</language>n";
$query = _STORYQUERY." ORDER BY updated DESC LIMIT 20";
$results = dbquery($query);
while($story = dbassoc($results)) {
$story['authors'][] = $story['penname'];
if($story['coauthors']) {
$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$story['sid']."'");
while($c = dbassoc($coauth)) {
$story['authors'][] = $c['penname'];
}
}
foreach($story['authors'] AS $k => $v) {
$story['authors'][$k] = strip_tags(xmlentities( $v));
}
$rss.= "<item>
<title>".strip_tags(xmlentities($story['title']))." "._BY." ".implode(", ", $story['authors'])."</title>
<link>$url/viewstory.php?sid=".$story['sid']."</link>
<description>[Rating: ".$ratings[$story['rid']]."] ".strip_tags(xmlentities($story['summary']))."</description>
<pubDate>".date("r",$story['updated'])."</pubDate>
</item>n";
}
$rss.="</channel>
</rss>";
header("Content-type: application/rss+xml");
header("Cache-Control: must-revalidate");
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 3600) . " GMT");
echo $rss;
?>
Any help with any or all of these amendments would be greatly appreciated.
xendt
OK, I've worked out on my own how to include categories in the RSS feed and I've found a solution to all issues except the chapter number issue.
Does anyone know how I can include the number of the last chapter in my RSS feed, so that when the announcement appears on my forum, members can see what the last chapter of that story is?
xendt
Moving this to MOD support as this isn't a general support request.
