Monday, January 25, 2010

XML Web Part/ RSS / Content Query Web Part Replacement in Windows SharePoint Services

Part 1
  • Add an XML Web Part to a page.
  • Edit the XML Web Parts properties
  • In the XML Link field, enter the URL of the RSS feed.
  • In the XSL Link field, enter the URL of an XSL file that you've written to transform the feed, or alternatively, in the “XSL Editor“, enter the following XSL code:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="tablebg"><table border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><img src="images/spcacer.gif" width="163" height="1" /></td>
</tr>
<tr valign="middle">
<td><h2>Recent Articles</h2>
</td>
</tr>
<xsl:for-each select="rss/channel/item">
<tr>
<td><a href="{link}"><xsl:value-of select="title"/></a></td>
</tr>
</xsl:for-each>
<tr>
<td><a href="/allarticles.aspx">More...</a></td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

Part 2
It wasn't too long ago that I was trying to get my favorite Web Part (Content Query Web Part) to pull an RSS feed form a SharePoint list. Web Part was giving me a lot of grief, repeatedly giving me the error:

Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator.

It took me a while to piece together that this Web Part does NOT run in the context of my given SharePoint credential when it comes to fetching this RSS. In fact I don't know of ANY RSS able Web Parts that support authenticated feeds.

As a work around I had to enable Anonymous Access for the given list. I was quite surprised when after some research I discovered that SharePoint allows you to turn on annonymous access for any of the following:

  • Everything on a site (ie. 3 sites out of a site collection)
  • Any combination of Lists and Libraries on a given site
  • No anonymous access at all

For my needs I wanted to turn it on for just ONE list (the one I wanted to expose and consume the RSS feed for). Here's how to do it.

Enabling Anonymous Access for a Single List

  1. The first thing you need to do is turn on anonymous access for the web application, this is done through the Central Administration UI. Open up the Central Administration web page, go to the Application Management tab and click on Authentication Providers under Application Security (see below).
  2. Now that this application allows anonymous access we need to turn it on for the given site. Go to the site you want to turn on anonymous access on, navigate to Site Actions->Site Settings->Modify All Site Settings. From here click on Advanced Permissions. Open up the Settings menu on the tool bar and then click Anonymous Access. Finally choose (for this example) "Lists and libraries". We're going to turn on anonymous access for exactly one list.
  3. Finally go to the list you want to turn on anonymous access for and in the List Settings, Permissions for this List and then expand the Settings menu and click Anonymous Access. From here you simply select the rights you want to give anonymous users for this list. In this case we simply choose View Items.
  4. That's it, that RSS feed should now be working!

1 comments:

Bryan K Geiger said...

I have found a work around solution for this problem. A SharePoint DataView with Server-Side Script RSS Feed. The key here is to use the guid for the list and the guid for the view.

Example:
http://demo1/_layouts/listfeed.aspx?List={GUID}&View={GUID}

Original article:
http://blog.jonathanroussel.com/2009/04/sorting-filtering-sharepoint-rss-feeds.html

Post a Comment