I've written an article on how to create an RSS feed in
Campsite:
http://code.campware.org/manuals/campsite/2.5/inde
x.php?id=162
(Campware's new RSS feed can be found here: http://www.campwa
re.org/en/camp/rss)
The text of this article follows:
---------------------------------------------------
Creating an RSS feed for your site
Requirements: You must have PHP wrapper installed.
Step 1) Create your RSS feed.
Create a template named "rss.tpl" and copy and
paste the template
written below. You will have to adjust the template tags to
fit your
site. For example, you should change the channel
information such as
the title and link, and the tags inside the
"<description>" element
("<!**print article intro> <!** print article
body>").
Notice that there is no "<?xml
version="1.0"...>" at the top of the
template - this is on purpose. If you put it in there the
PHP wrapper
will think this is PHP code and try to execute it. Since it
isnt real
PHP code, the PHP wrapper will crash and show you an error.
Also note that the publish date can only be specified to the
day, not
the hour and minute. This will be fixed in Campsite 2.6.
The PHP code at the beginning and end of the sample below is
so that
the HTTP header is set to "text/xml" instead of
"text/html".
Step 2) Create the link to your RSS feed.
You can do this by using the "URI" keyword:
<!** local>
<!** publication off>
<!** issue off>
<!** section off>
<a href="http://your_site_name<
a>!** URI template rss.tpl>">RSS Feed</a>
<!** endlocal>
------------------------------------------------------------
-----------
rss.tpl
------------------------------------------------------------
-----------
<?php
ob_start();
?>
<rdf:RDF xmlns:rdf="http://ww
w.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/
"
xmlns:dc="http://purl.org/dc/e
lements/1.1/">
<channel rdf:about="http://www.campware.org&
quot;>
<title>Campware News</title>
<link>http://www.campw
are.org</link>
<description>Free Software for a Free
Press</description>
<dc:language>en-us</dc:language>
<items>
<rdf:Seq>
<!** Local>
<!** language English>
<!** publication name campware>
<!** issue current>
<!** section off>
<!** list length 20 article OnFrontPage is on
order bydate desc>
<rdf:li rdf:resource="http://www.campware.org&l
t;!** URI>"/>
<!** EndList>
<!** EndLocal>
</rdf:Seq>
</items>
</channel>
<!** Local>
<!** language English>
<!** publication name campware>
<!** issue current>
<!** section off>
<!** list length 20 article OnFrontPage is on order
bydate desc>
<item rdf:about="http://www.campware.org&l
t;!** URI>">
<title><!** print article
name></title>
<link>http://www.campware.org&l
t;!** URI></link>
<description><![CDATA[<!** print article
intro> <!** print
article body>]]></description>
<dc:date><!** print article publishDate
"%Y-%m-%d">T00:00:00+00:00</dc:date>
</item>
<!** EndList>
<!** EndLocal>
</rdf:RDF>
<?php
header("Content-type: text/xml");
$content = ob_get_clean();
echo '<?xml version="1.0"
encoding="utf-8"?>';
echo $content;
?>
------------------------------------------------------------
-----------
Tips & tricks
If you use XSL, the CDATA sections do not work with Firefox.
If you dont want to use CDATA sections in your RSS, you can
strip the
HTML from your article this way:
$allowedTags="<rdf:RDF><rdf:Seq><rdf:li
><channel><title><link><description&
gt;<dc:language><dc:date><item><items&g
t;";
$content = strip_tags($content, $allowedTags);
Another way to create a link to your RSS feed
Assign the template to a section: create a new section
(doesnt matter
where), and call it "rss". Configure the section
so that its templates
are "rss.tpl", and give the section the URL name
of "rss". The URL for
this section will be the URL to your RSS feed.
|