Slug: how-to-rss-in-conversant Date: 2000-10-13 Title: “How-To: RSS in Conversant” layout: post
Gotta Have It
I'm a big proponent of using XML to extend the reach of my content. And, for that matter, to do lots of other things. So when I discovered that Conversant did not have the ability to output RSS from the weblog data I had been entering, I was disappointed.
Not For Long
After a while I discovered that one can do very clever things with Conversant's templates. "Jim" did an XML document, and mentioned that he had done it with Conversant's WebOutline and some templates… which of course got me thinking.
The way to get Conversant to generate RSS, in short, is a combination of a custom query page, templates, and some abuse of the HTML-Enforcer. So, let's get on to it!
I first spent some time with the built-in query page on Redmonk.Net. I did some searches to find out just what kind of flexibility I have. What I wanted was the last ten posts to my weblog, ordered most recent first. Play around with your query page to get just the kind of results you want in your RSS file. Idea: themed RSS files, using the Label feature to limit results to one category.
Lie to the Enforcer
Once you know what information you want, but before we do the templates, we have to convince the HTML Enforcer plug-in in Conversant to leave our XML tags alone, lest it neuter them when you save the template.
So, add the following tags to the HTML Enforcer's list of allowed tags: "xml", "rss", "channel", "item", "description", "managingEditor", "webMaster", "title", "link", "language", "copyright".
Conversant exposes an almost bewildering array of templates for the use of the site developer. That's a great thing in this case, because we're going to use three of them.
The first is a new page-level template, that provides the wrapper of the RSS file (<?xml?><rss>…). Create the template and set it to something like this: (make the necessary changes to customize the content for your site)
<?xml version="1.0"?> <rss version="0.91"> <channel> <title>(what's your rss file called?)</title> <link>(your site url)</link> <description>(your description)</description> <language>en-us</language> <copyright>(your copyright statement)</copyright> <managingEditor>(email address)</managingEditor> <webMaster>(email address)</webMaster> <!--#pageContent--> </channel> </rss>
Next up are the templates on your new query page. If you haven't already, create a new query page, and set the template to the new template you just created. I called my new page "recentStuff.rss".
Now we move on to the three templates that a query page uses: the Query Form template, the Search Result Page template, and the Search Result Items template.
The Query form appears on the page with the results, so just delete it altogether. This query page will have to be called from hard-coded links. (For now…)
Next we set the Search Result Page template:
That's it! Everything else is in the Search Result Items template.
The Search Result Items template:
<item> <title><!--#searchResultMsgSubject--> [<!--#searchResultMsgLabelName-->]</title> <link>(your site url)/</link> <description></description> </item>
OK - that's it! Customize your templates as you want - I've got the basics in there, but you could add more or less information as you desire. Make sure your templates have no extra carraige returns, as Conversant will <p> them if there are!
As I mentioned before, you have to use hard coded links right now, though I'd like to see that change. Remember the query you devised earlier? Submit the query on your usual search page, then copy and paste the parameters into a link to your new RSS query page. Better yet, save some typing or copy-and-pasting and create a new Resource that points to your RSS page.
[Feature Request] One last thing: It'd be really nice if we could then set the MIME content-type for this page to text/xml, since Conversant currently still serves the page as text/html, and the browsers don't know what to do with it.
P.S. - My RSS file is linked from this page.