Home : Products : Gossamer Forum : Development, Plugins and Globals :

Products: Gossamer Forum: Development, Plugins and Globals: Re: [gotze] RSS / XML Output for Ten Most Recent Postings: Edit Log

Here is the list of edits for this post
Re: [gotze] RSS / XML Output for Ten Most Recent Postings
1/8/03 UPDATE:
This gizmo is still in-process, since invalid characters are allowed to creep into your xml. See later posting. Back to the orginal posting:

Nice John, I'm testing something similar. This was pieced from other postsings here - which I'm too lazy to credit. It should xml-ize the last ten posts (controlled by hot_threads variable).

This should allow for a short quote of the post to be displayed too.


http://nerock.com/cgi-bin/gforum/gforum.cgi?do=search_results&search_time=10h&t=rssmod

Step 1
Create two new global variables:

hot_threads


sub {
my $tags = shift;
my $post_db = $DB->table ('Post');
$post_db->select_options ('WHERE post_root_id=0',
'ORDER BY post_time DESC', 'LIMIT 10');
my $sth = $post_db->select;
my @output;
while (my $post = $sth->fetchrow_hashref)
{
push @output, $post;
}

return { post_loop => \@output };
}


hot_chop update: see later post below for improved hot_chop


sub {
my $post_message = shift;
return substr($post_message,0,125);
}


Step 2
Create a new directory / template set - called rssmod with two new templates:

.tplinfo


{
inheritance => '../default'
}


search_results.html


<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="0.91">
<channel>
<title>Your Title</title>
<link>http://yousite.com</link>
<description>Your Description</description>
<language>en</language>

<%hot_threads%>
<%loop post_loop%>
<item>
<title><%post_subject%></title>
<link>http://www.yoursite.com/gforum/gforum.cgi?post=<%post_id%></link>
<description><%hot_chop($post_message)%></description>
</item>
<%endloop%>
</channel>
</rss>

Last edited by:

DoubleJJ: Jan 13, 2003, 5:56 PM

Edit Log: