How to make an RSS feed in Domino
After a little googling, I found out what RSS feeds are and how to build them. So I need an XML entry for the blog description itself and one for each post. This will all fit nicely in a Notes view, rendered with a special $$Viewtemplate. Easy. Because I want to make my applications as fast as possible, I choose to pre-render the XML needed in computed fields rather than assembling them with view column formulas. After all: they only change when a document is saved.
The blog description
A computed field "Content_RSS" on my DbConfig form
nl:=@NewLine;
"<title>"+Subject+"</title>"+nl
+"<link>"+PermalinkBase+"</link>"+nl
+"<description>"+Description+"</description>"+nl
The blog entries
A computed field "Content_RSS" on my Blog entry form
nl:=@NewLine;
pb:=@Middle(dbProfile; "<permalinkbase>"; "</");
"<item>"+nl
+"<title>"+Subject+"</title>"+nl
+"<description>"+Description+"</description>"+nl
+"<link>"+pb+Permalink+"</link>"+nl
+"<guid>"+pb+Permalink+"</guid>"+nl
+"</item>"+nl
The RSS view
I called the view: "feed"; view selection: all published blog entries
first column: PostedDate, sorted descending, hidden
second column: Content_RSS (field)
Don't forget: Show view as HTML
The RSS viewtemplate
Create a form "$$ViewTemplate for feed"
In the form properties, tab Defaults, change the Character set to UTF-8. For testing, set the Content type to other: text/xml. On the form, we have to put some XML, a Computed text to retrieve the blog description and a $$ViewBody field to get the XML of the posts:
<?xml version="1.0"?>
<rss version="2.0">
<channel>
[<computed text>]
[$$ViewBody]
</channel>
</rss>
The code for the computed text:
a:=@GetProfileField("Domino";"dbprofile");
b:=@GetDocField(a; "Content_RSS");
@If(@IsError(b); @Text(b); b)
The result is valid XML, as we can check by opening this view in a browser:
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Domino 2.0</title>
<link>http://localhost/domino/</link>
<description>This blog is dedicated exclusively to programming
and coding techniques for the Internet using Lotus Notes/Domino. So
it's main target audience is Notes developers who make Internet
applications using Semantic HTML, CSS, Ajax, SEO, usability and
Web 2.0 patterns.</description>
<item>
<title>Search Engine Optimisation for Domino Web applications</title>
<link>http://localhost/domino//archives/2006-10-10-search-engine-
optimisation-for-domino-web-applications</link>
<description>Why do domino powered sites score badly in Google?
Find out why and how you can make Domino score high with search
engines.</description>
</item>
<item>
<title>A quick RSS feed in Domino</title>
<link>http://localhost/domino//archives/2006-10-03-a-quick-rss-feed-in-
domino</link>
<description>No blog is complete without having a RSS feed. And making one
in Domino is dead easy.</description>
</item>
</channel>
</rss>
Once we know it's valid XML, we can change the Content type of the $$ViewTemplate to "application/rss+xml" and validate it.
Adding the feed to my blog
The last thing I had to do is adding a line of code in the </head>:
"<link rel=\"alternate\" type=\"application/rss+xml\"
title=\"RSS 2.0\" href=\"/domino/feed.xml\" />"
Comments
03/03/2009 16:11:41, Mohammed Yunus
Hi how would it look in a database have you any examples. Thanks
To add a comment, log in or register as new user. It's free and safe.