In a previous article I have discussed how to create an RSS feed for a MCMS site.
So the next logical step is to discuss how a RSS feed can be agregated in a MCMS site - and it should be possible that content authors can configure the Feed Url and other parameters while authoring the site.
To ensure this we will create a MCMS RSS Agregator custom placeholder control.
Creating Authoring and Presentation Child Controls
The placeholder control needs to render different child controls during authoring time and during presentation time: During authoring the author should be able to configure the aggregated feed and in presentation time the information retrieved from the configured feed should be rendered in the configured way.
Let's first focus on the authoring time controls. I choosed the following configuration options for the control:
To give the author these configuration options we render TextBox, CheckBox and DropDownList controls. The placeholder control will utilize an XmlPlaceholder object to store the configuration information.
Now after we have created the authoring time controls we need to render the presentation time controls - but this is a quite simple job as we will use a Literal control to hold this data.
Implementing the Save Placeholder Content methods
As indicated before we will store the configuration information for the placeholder control inside a XmlPlaceholder object. To do this we need to wrap the configuration information inside a XmlStructure before saving this structure inside the bound XmlPlaceholder object.
Implementing the Load Placeholder Content methods for Authoring and Presentation mode
The first step is to remove the XML wrapper from the content in the XmlPlaceholder. After this we can use this content and either add the content directly to the Child controls (Authoring Mode) or to do run an HttpRequest against the configurerd Feed URL and create the desired html based on the returned feed information and the configuration information from the XmlPlaceholder object.
First I tried to use an XML/XSLT transformation to generate the html directly but due to the fact that I found that the different RSS feeds use different schemas to provide the same information. I finally ended up by directly parsing the XML stream and generating the Html manually. If someone has more experience with XML/XSLT and can provide a transformation XSLT file which will work with all kind of RSS feeds: please send it to me and I will adjust my placeholder control.
My small RSS-XML parser looks for the following XML tags to identify the different elements in the feed:
I tested this parser with around 50 feeds and it worked fine with all of them.
Here are some screenprints on how the controls works:
I have uploaded the control to GotDotNet.
Nice! But what does the link "Save & Exit with ReleaseOwnership" do?
I have a console extension active. Saving the posting with this option allows any other user to continue to work on the posting.
This is not related to the RssAggregator.
In questo post viene illustrato come sfruttare RSS con MCMS.