Description:
This box will export, in real time, the last 10 stories from a user. Clearly you'll have to clean the photographica crud out and replace it with your own. You'll also have to create an op and assign it to this box (preferably rss_export), you'll also want to make sure the template you use is completly blank besides the content this guy returns.
I suggest its companion, rss_story; a story display that will show a story's contents, and two other stories from the site.
Box Code:
use XML::RSS;
my $uid = $S->{DBH}->quote($S->{CGI}->param('user_id'));
my ($rv, $sth) = $S->db_select({
WHAT=>'*',
FROM=>'users',
WHERE=>"uid=$uid"});
my $user = $sth->fetchrow_hashref();
return "" unless($$user{nickname});
# 2.0 is awesome too ya know!
my $rss = new XML::RSS (version => '1.0');
# modify for your own site.
$rss->channel(
title => "Photographica: $$user{nickname}",
link => "http://www.photographica.org",
description => "$$user{nickname}'s last 10 Photographica stories",
);
# if you so desired, you could limit this down to just diaries or something...
($rv, $sth) = $S->db_select({
WHAT=>'sid, title, story_picture',
FROM=>'stories',
WHERE=>"aid='$$user{nickname}'",
ORDER_BY=>'time DESC',
LIMIT=>'10'
});
while(my $story=$sth->fetchrow_hashref())
{
# change this link to /story/$$story{sid} if you so desire
$rss->add_item(
title=>$$story{title},
link=>"http://www.photographica.org/rss_story/?sid=$$story{sid}"
);
}
return $rss->as_string();
|