Search the web
Sign In
New User? Sign Up
RSS2-Support
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Question about RSS...and how to generate file dynamically.   Message List  
Reply | Forward Message #353 of 807 |
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





Mon Jul 28, 2003 8:17 pm

ariusuk
Offline Offline
Send Email Send Email

Forward
Message #353 of 807 |
Expand Messages Author Sort by Date

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...
Tim Gray, formula-300...
ariusuk
Offline Send Email
Jul 28, 2003
8:20 pm

This is actually kinda tricky because the xml statement at the top of the RSS file uses the same delimiter as PHP. It looks like this: <?xml version="1.0" ?>...
Derek Scruggs --> Esc...
derekscruggs
Offline Send Email
Jul 28, 2003
8:51 pm

I use the following script for my blog. The blog is entirely PHP with a MySQL backbone. http://www.io.com/~phlbbrtn/blog/ I use a cron job on the server to...
phlbbrtn
Offline Send Email
Jul 29, 2003
12:32 am

Aren't there any XML libraries available for PHP?...
Danny Ayers
danny_ayers
Offline Send Email
Jul 29, 2003
9:41 am

... I should have said that the cron job utilizes "lynx -source -dump" to output to the RSS file. Works just great....
phlbbrtn
Offline Send Email
Jul 29, 2003
10:05 am

... Um, wget seems to have more options and is less likely to 'be difficult'. There's also curl. My past experiences with lynx lead me to believe it's not the...
Bill Kearney
wkearney99
Offline Send Email
Jul 29, 2003
1:41 pm

... greatest at ... Sure, whatever. I am just telling what works for me. What "works for me" is fully automated and requires no ongoing maintenance. I did not...
phlbbrtn
Offline Send Email
Jul 29, 2003
3:00 pm

... Likewise, I found lynx's lack of features found in wget and curl to be a problem as my programming needs grew. Like using authentication and cookies. ... ...
Bill Kearney
wkearney99
Offline Send Email
Jul 29, 2003
3:18 pm

I think this pointless discussion is 50 miles wide of the point. You don't like what I use productively every day? That's your right. Someone asked for a way...
phlbbrtn
Offline Send Email
Jul 29, 2003
5:37 pm

There seems to be some confusion with this issue, so I hope no-one will feel I'm attempting to patronise them if I try and cover all bases. First of all, I'd...
Wechsler
biosoft.geo
Offline Send Email
Jul 29, 2003
6:25 pm

... Thanks, I was wondering - seemed strange to do all the escaping etc inline in this day and age... ... Right, that sounds rather more like it. Cheers, ...
Danny Ayers
danny_ayers
Offline Send Email
Jul 29, 2003
7:03 pm

... PHP lets you generate XML using DOM. There's no need to hand code it, if you don't want to. Whether you want to for a task like this is another question. ...
trachtenberga
Offline Send Email
Jul 29, 2003
7:28 pm

... Thanks, I just did a bit of nosing around and found RAP RDF parser, so if anyone wants to do anything more sophisticated than a reader one possiblity would...
Danny Ayers
danny_ayers
Offline Send Email
Jul 30, 2003
1:28 pm

... of ... I had experimented by just modifying the php file - but that was the line I was missing. Thanks to everyone for their help. Tim...
ariusuk
Offline Send Email
Aug 1, 2003
8:48 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help