Having spent the last couple of days looking at RSS, you've got me convinced
that my websites (or the news-based ones at least) should be offering an RSS
feed of the most recent news stories.
I've had no problem making a test file and looking at it in a newsfeed
reader.
But it occurs to me that as the news stories on my sites are all dynamically
indexed using php, there must be an easier way of updating that RSS feed
when I add a new story, than to open the file in notepad, create a new item
at the top, and delete the oldest one from the bottom, then save the file
and upload it to the server.
However there doesn't appear to be a way of including any php in the RSS
file.
Here's how the php works on the new index page of the website:
<?php
$dir_name="archive";
$dir = opendir($dir_name);
$basename = basename($dir_name);
$fileArr = array();
while ($file_name = readdir($dir))
{
if (($file_name !=".") && ($file_name !=".."))
{
$fName = "$dir_name/$file_name";
$fTime = filemtime($fName);
$fileArr[$file_name] = $file_name;
}
}
arsort($fileArr);
$numberOfFiles = sizeOf($fileArr);
if($numberOfFiles>32)
{ $numberOfFiles=32;
}
for($t=0;$t<$numberOfFiles;$t++)
{
$thisFile = each($fileArr);
$thisName = $thisFile[0];
$thisTime = $thisFile[1];
$thisTime = date("d M y", $thisTime);
$thisPath = "archive/".$thisName;
$buffer= file($thisPath);
$head = $buffer[2];
$body = $buffer[7];
$date = $buffer[4];
echo"<tr bgcolor=#cccccc><td><font size=2>$date</td><td><font size=2><a
id=nu href=$thisPath><b>$head</b></a></td></tr>";
}
closedir ($dir);
?>
As you can see it's produced a series of strings which would be perfect to
integrate into the RSS feed:
$thisTime for <pubDate>
$head for <title>
$body for <description>
and
$thisPath for <link>
Can anyone help?
Tim