I think it might be a nice touch ... I've seen on some custom fiction archives, they also have "favourite stories RSS feeds" but I'm more curious about author RSS feeds at the moment.
Is it possible?
I might try this, but I'm still getting used to how eFiction is coded. Though, I'm sure it would be a simple matter of borrowing a few things from rss.php and editing them? :S
archive:
site:
Available for skin/mod commission! π
I setup an author RSS feed for my site. All you need to do is pass the user ID and it comes back with a list of there stories.
Nothing fancy, just a modification of the standard RSS feed, changing the query and accepting the input. This is the code as it stands, but I am sure it can be improved upon
<?php
define ("_CHARSET", "ISO-8859-1");
define("_BASEDIR", " http://****** ");
require_once("//includes/mysql_functions.php");
require_once("/****/eFiction/config.php");
$user =(int) $_GET[user];
if($user)
{
function xmlentities ( $string )
{
return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&' , '"', ''' , '<' , '>' ), $string );
}
$rss="<?xml version='1.0'?>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>The World of Necrotania - My Stories</description>n";
$rss.="<link> http://www.necrotania.com/eFiction/</link>n";
$rss.="<title>The World of Necrotania - My Stories</title>n";
$rss.="<managingEditor>$siteemail</managingEditor>n";
$rss.="<webMaster>$siteemail</webMaster>n";
$rss.="<language>en-us</language>n";
$query = "SELECT title, sid, summary, username, rid, unix_timestamp(updated) from ".$tableprefix."fanfiction_stories as s,vb_user as a WHERE a.userid = s.uid AND s.validated > 0 AND s.uid = ".$user." ORDER BY updated DESC";
$results = mysql_query($query) or die(_FATALERROR."Query: ".$query."<br />Error: (".mysql_errno( ).")");
while($story = mysql_fetch_array($results)) {
$rss.= "<item>
<title>".strip_tags(xmlentities($story[title]))." ".By." ".strip_tags(xmlentities( $story[username]))."</title>
<link> http://www.necrotania.com/eFiction/viewstory.php?sid=$story [sid]</link>
<description><![CDATA[".$story[summary]."]]></description>
<pubDate>".date("r",$story[5])."</pubDate>
</item>n";
}
$rss.="</channel>
</rss>";
header('Content-type: text/xml');
echo $rss;
} else {
echo "Invalid Input";
}
?>
Wow, thanks, calash.
I've edited it, so it works but I'll see about playing around with it further. π
archive:
site:
Available for skin/mod commission! π
ok im really new to the whole RSS feeds thing and Im thinking of giving this a go but would it be the default RSS file that you edit or do you create a new file for this? (sorry like I said I dont know alot about RSS)
but I do know that to get the RSS feeds you need a bit of reader software so can anyone recommend any that are good?
thanks for the help π
~Spikey~
my site url: http://www.fanfictionworld.org
efic version:3.5.3
The code I posted was a modification of the default RSS code (A couple of versions back if I remember). You will want to create a new file, so you do not lose the main RSS feed.
As for a reader, IE 7.0 actually does a good job of it..so you can test in your browser. Firefox is another one I use to make sure feeds are coming out good.
I setup an author RSS feed for my site. All you need to do is pass the user ID and it comes back with a list of there stories.
Nothing fancy, just a modification of the standard RSS feed, changing the query and accepting the input. This is the code as it stands, but I am sure it can be improved upon
Okay so how do you "pass the user ID"?
http://www.trackbunnies.org
http://blog.trackbunnies.org/
http://karah-leighhancock.avonrepresentative.com/
myrss.php?user=#
Number is the user ID you want the feed for.
Note:
$user =(int) $_GET[user];
if($user)
I've edited the code so if the user isn't passed, the regular RSS feed gets passed. The code is somewhat personalised to my own website, but if you mess around with:
else {
echo "Invalid Input";
}
You can get it. π
archive:
site:
Available for skin/mod commission! π
How would we link the rss feed from each profile though? Gah, this is what I get for being a senior in college, I forget everything that pertains to my non-college life LMFAO!
http://www.trackbunnies.org
http://blog.trackbunnies.org/
http://karah-leighhancock.avonrepresentative.com/
From the top of my head ...
Go into profile.php and make a new a variable and use it in the template. :3
archive:
site:
Available for skin/mod commission! π
How would we link the rss feed from each profile though? Gah, this is what I get for being a senior in college, I forget everything that pertains to my non-college life LMFAO!
I am looking at custom profile fields right now, but it looks like they are all set not to display unless they have information in them. The other option I am looking at is to use the profile.php hook, it is right before the admin link list, so setting a tpl variable there would be perfect to include the link.
You could also edit ether profile.php or variables.php and have it set the variable at that point too.
I am going to play around with the hook, think it will be the easiest to maintain through upgrades and such.
Jenny, Very good point on combining the two feeds. It may be more efficient, as in less code, to change the check location to the queries, since that is really the primary difference. If there is a user ID it runs that query, if not it runs the standard query. The rest will be the same code and eliminate duplication.
If I get some time today I will throw it all together and see if what I am thinking will work π
Been thinking about this a bit, I am wondering if this would better be suited for variables.php than a profile.php edit, that way you can add or remove it based on what skin you use.
For a variable.php edit you can add this code
$myrss = "<a href="'rss.php?user=$uid'>My" RSS Feed</a>";
$tpl->assignGlobal("myrss", $myrss);
Then in profile.php add {myrss} where you want the link to show up. This code assumes you replaced the default rss.php with the author rss feed, so edit as needed.
Using the hook would be a bit cleaner, but it seems almost too simple of an addition to add to a hook.
This is the current rss.php with the modification to accept the user id being passed. If it is not valid it returns the standard rss feed.
<?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");
$settings = dbrow($settingsresults);
foreach($settings as $var => $val) {
$$var = $val;
}
define("TABLEPREFIX", $tableprefix);
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");
$url=" http://www.necrotania.com/eFiction";
$sitename = "The World of Necrotania - Fantasy and Science Fiction Writing";
$language = "en";
$slogan = "Fantasy and Science Fiction Writing Community and Archive.";
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>webmaster@necrotania.com</managingEditor>n";
$rss.="<webMaster>webmaster@necrotania.com</webMaster>n";
$rss.="<language>$language</language>n";
$user =(int) $_GET[user];
if($user)
{
$query = _STORYQUERY." AND uid = $user";
} else {
$query = _STORYQUERY." ORDER BY updated DESC LIMIT 20";
}
$results = dbquery($query);
while($story = dbassoc($results)) {
$rss.= "<item>
<title>".strip_tags(xmlentities($story['title']))." "._BY." ".strip_tags(xmlentities( $story['penname']))." [".$ratings[$story['rid']]."]</title>
<link>$url/viewstory.php?sid=".$story['sid']."</link>
<description>".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;
?>
Make sure to fix the hard coded stuff in the header area...parts of the feed were missing and I patched it together a while back. The key part is the query code
$user =(int) $_GET[user];
if($user)
{
$query = _STORYQUERY." AND uid = $user";
} else {
$query = _STORYQUERY." ORDER BY updated DESC LIMIT 20";
}
You can even take it a step further and put this before you setup the RSS feed header info, allowing you to have a different feed title and author info. This code should be more in line with the eFiction standards than my other code...both work though π
