RSS Viewer Webpart In Sharepoint

In this blog, I will explain how to use RSS Viewer web part to display feeds from external websites to the SharePoint portal.

Introduction

Using this RSS Viewer Web Part, you can display data like weather and news from external sites into your SharePoint site. Let’s see how to get started with it.

Navigate to SharePoint portal.

Click on Edit page - > Add a Webpart.

Under content roll-up -> pick RSS Viewer.

RSS Viewer Webpart

After adding this web part, click on "Edit web part".

I am getting the feed from my website http://sharepointanchor.com/feed/

RSS Viewer Webpart

Now, just expand the RSS Properties.

Pass the RSS Feed URL.

RSS Viewer Webpart

We can also set the row limit of feeds. This will help you to display the top 5 to 10 numbers from the external sites.

I myself set the Feed limit to 10.

RSS Viewer Webpart

Also, you can set the feed refresh time. This helps to refresh the feed from the external site to view the recently updated content in your SharePoint portal.

I'm going to change “60 sec” and reduce to 1 minute.


RSS Viewer Webpart

Click "Apply" and check.

RSS Viewer Webpart
So now, the Feed has been displayed in your SharePoint portal from your external site. One thing has been missing from the output; i.e., User Interface. Now, I am going to customize this using XSLT Template.

Click on Edit webpart -> at the end, you are able to see the data view properties.

RSS Viewer Webpart

Click "XSL Editor".

I'm going to change the View to the table.

Just find the XSL named “RSSMainTemplate.body”.

Add the table header.

Code

  1. <table border="1">  
  2.     <tr bgcolor="#9acd32">  
  3.       <th style="text-align:left">Blog Title</th>  
  4.         </tr>  
  5. Next remove the default div start “<div class="item link-item" >” End tag “</div>”  
  6. Add a table row <tr> and table data <td> enclosed with  <a href>  
  7.              <tr>  
  8.                       <td>  
  9.                             <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}" >  
  10.                                 <xsl:value-of select="title"/>  
  11.                             </a>  
  12.                             <xsl:if test="$rss_ExpandFeed = true()">  
  13.                                 <xsl:call-template name="RSSMainTemplate.description">  
  14.                                     <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>  
  15.                                     <xsl:with-param name="CurrentElement" select="$CurrentElement"/>  
  16.                                 </xsl:call-template>  
  17.                             </xsl:if>  
  18.                             <xsl:if test="$rss_ExpandFeed = false()">  
  19.                                 <xsl:call-template name="RSSMainTemplate.description">  
  20.                                     <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>  
  21.                                     <xsl:with-param name="CurrentElement" select="$CurrentElement"/>  
  22.                                 </xsl:call-template>  
  23.                             </xsl:if>  
  24.                         </td>  
  25.                         </tr>                     
  26.                 </xsl:if>  
  27.             </xsl:for-each>  
  28.              </table>  

Full section looks like the following.

  1. <xsl:template name="RSSMainTemplate.body" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">  
  2.           <xsl:param name="Rows"/>  
  3.           <xsl:param name="RowCount"/>  
  4.            <table border="1">  
  5.   <tr bgcolor="#9acd32">  
  6.     <th style="text-align:left">Blog Title</th>  
  7.       </tr>  
  8.           <xsl:for-each select="$Rows">  
  9.               <xsl:variable name="CurPosition" select="position()" />  
  10.               <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />  
  11.               <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />  
  12.               <xsl:if test="($CurPosition <= $rss_FeedLimit)">  
  13.                     <tr>  
  14.                     <td>  
  15.                           <a href="{concat("javascript:ToggleItemDescription('",$CurrentElement,"')")}"  style="color: tomato;">  
  16.                               <xsl:value-of select="title"/>  
  17.                           </a>  
  18.                           <xsl:if test="$rss_ExpandFeed = true()">  
  19.                               <xsl:call-template name="RSSMainTemplate.description">  
  20.                                   <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>  
  21.                                   <xsl:with-param name="CurrentElement" select="$CurrentElement"/>  
  22.                               </xsl:call-template>  
  23.                           </xsl:if>  
  24.                           <xsl:if test="$rss_ExpandFeed = false()">  
  25.                               <xsl:call-template name="RSSMainTemplate.description">  
  26.                                   <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>  
  27.                                   <xsl:with-param name="CurrentElement" select="$CurrentElement"/>  
  28.                               </xsl:call-template>  
  29.                           </xsl:if>  
  30.                       </td>  
  31.                       </tr>                     
  32.               </xsl:if>  
  33.           </xsl:for-each>  
  34.            </table>  
  35.       </xsl:template>  

Just paste the updated XSL Code on the window. Click OK. 

Finally, the output looks like this.
RSS Viewer Webpart
Click on the link to read the description.

RSS Viewer Webpart

Click on the "more" link to redirect to the external site.

RSS Viewer Webpart 

Conclusion

In this article, you learned how to feed the external site information into your SharePoint portal with a custom design. Hopefully, it will be helpful for SharePoint developers, beginners, SharePoint administrators, and business professionals who are using SharePoint.

Happy SharePointing!