Skip to main content

Cloud

How do I customize the look and feel of the out of the box RSS viewer?

Today I was trying to figure out how I could customize the look and feel of the out of the box SharePoint RSS feed.

There are two ways to do this. The first is to edit the XSL right in the web part by clicking on the "XSL Editor…" button within the web part and modifying the XSL that comes up in the window.

Doing this will edit the XSL associated with this RSS web part instance and no other instances of the RSS web part will be affected. The downfall with this approach is that if you need to change the look and feel of a bunch of different web parts after they have been created you have to touch each one.

The second way is a bit more flexible with respect to changing the look and feel of multiple web parts after they have been created. After much searching, I found the XslLink property of the Microsoft.SharePoint.Portal.WebControls.RSSAggregatorWebPart. This property lets you set an external URL that will be loaded to style the RSS feed being grabbed by the web part. This URL must be a full URL that starts with protocol type, ie "http://" "or https://", and cannot be a URL that starts with a "/". It took me a while to figure this one out. I wish it were documented in the API docs as I feel that they need some help but after some research I finally got this to work. The secret is changing the web part definition that gets exported to include the following:

<property name="Xsl" type="string" null="true" />

<property name="XslLink" type="string">http://server.yourdomain.com/sites/yourSite/Style%20Library/XSL%20Style%20Sheets/test.xsl</property>

This process is very similar to the process that one would use to add custom fields to a content query web part. You export the web part, add the fields and then re-import the web part. If you don’t know what I am talking about, I would suggest you read the blog entry about it here. Another upside to using this method is that you could save the customized web part file (.webpart) to the Web Part Gallery (Site Actions -> Web Parts) and allow users to easily add this customized web part to any web part zone. If you are planning on doing this, I would suggest modifying the RssViewer.webpart file present in the Web Part Gallery and resaving it to the gallery under a different name. The file that you export will have a complete listing of the exported web part properties, many of which you will not want.

As you can see from the code above, I am pointing to a style sheet that lives in the same location that the publishing feature places all of its XSL style sheets. This URL does not have to be a full URL (one that starts with "http://") but can also be a one that just uses the current server (starts with "/"). You could point multiple RSS web parts to the same style sheet or point them to many different ones. Changing the styles is as simple as uploading a new style sheet.

Please let me know if you have any issues with this. It should at least get you started down this path.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dave Scheele

More from this Author

Follow Us