RSS Viewer Webpart In Sharepoint

0
154
views

Download Code: xsl

In this article, I have explained about RSS Viewer webpart to display feeds from external websites to sharepoint portal

Introduction:

Using this RSS Viewer Webpart you are able to display the data like weather, news, from external sites into your sharepoint site

Let’s go and see how to use a RSS Feed webpart

Navigate to sharepoint portal

Click on Edit page – > Add a Webpart

Under content rollup -> Pick RSS Viewer

After adding this webpart -> Click on Edit webpart

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

Now Just expand the RSS Properties

Pass the RSS Feed  URL  whatever I get it from external sites myself add it from my blog site

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

Myself am set the Feed limit as “10”

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

By default, we can get “120 sec” probably 2 minutes

Am going to change this a “60 sec” reduced to 1 minutes

Click Apply and check

So now the Feed has been displayed in your sharepoint portal from external site

One thing has been missed out from this output the thing is User Interface

Now am going to customize this using XSLT Template

Click on Edit webpart -> At the End you are able to see the data view properties

Click On XSL Editor

Am going to change the view to table

Just find the Xsl Name “RSSMainTemplate.body”

Add the table header

Code:

<table border="1">

    <tr bgcolor="#9acd32">

      <th style="text-align:left">Blog Title</th>

        </tr>

Next remove the default div start “<div class=”item link-item” >” End tag “</div>”

Add a table row <tr> and table data <td> enclosed with  <a href>

             <tr>

                      <td>

                            <a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}" >

                                <xsl:value-of select="title"/>

                            </a>

                            <xsl:if test="$rss_ExpandFeed = true()">

                                <xsl:call-template name="RSSMainTemplate.description">

                                    <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>

                                    <xsl:with-param name="CurrentElement" select="$CurrentElement"/>

                                </xsl:call-template>

                            </xsl:if>

                            <xsl:if test="$rss_ExpandFeed = false()">

                                <xsl:call-template name="RSSMainTemplate.description">

                                    <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>

                                    <xsl:with-param name="CurrentElement" select="$CurrentElement"/>

                                </xsl:call-template>

                            </xsl:if>

                        </td>

                        </tr>                  

                </xsl:if>

            </xsl:for-each>

             </table>

Full Code section looks:

  <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">

            <xsl:param name="Rows"/>

            <xsl:param name="RowCount"/>

             <table border="1">

    <tr bgcolor="#9acd32">

      <th style="text-align:left">Blog Title</th>

        </tr>

            <xsl:for-each select="$Rows">

             <xsl:variable name="CurPosition" select="position()" />

                <xsl:variable name="RssFeedLink" select="$rss_WebPartID" />

                <xsl:variable name="CurrentElement" select="concat($RssFeedLink,$CurPosition)" />

                <xsl:if test="($CurPosition &lt;= $rss_FeedLimit)">

                      <tr>

                      <td>
                       <a href="{concat(&quot;javascript:ToggleItemDescription('&quot;,$CurrentElement,&quot;')&quot;)}"  style="color: tomato;">

                                <xsl:value-of select="title"/>

                            </a>

                            <xsl:if test="$rss_ExpandFeed = true()">

                                <xsl:call-template name="RSSMainTemplate.description">

                                    <xsl:with-param name="DescriptionStyle" select="string('display:block;')"/>

                                    <xsl:with-param name="CurrentElement" select="$CurrentElement"/>

                                </xsl:call-template>

                            </xsl:if>

                            <xsl:if test="$rss_ExpandFeed = false()">

                                <xsl:call-template name="RSSMainTemplate.description">

                                    <xsl:with-param name="DescriptionStyle" select="string('display:none;')"/>

                                    <xsl:with-param name="CurrentElement" select="$CurrentElement"/>

                                </xsl:call-template>

                            </xsl:if>

                        </td>

                        </tr>                  

                </xsl:if>

            </xsl:for-each>

             </table>

        </xsl:template>

Just Paste the updated XSL Code on the window

Click Ok

Finally, the output look like this

Click on the link to read the description

Click on the more link to redirect to the external site

 

 

Conclusion:

In this article, you can able to feed the external site information into your sharepoint portal with custom design. Hopefully It will be helpful for sharepoint developers, beginners, sharepoint administrators and business professional having sharepoint.

Happy sharepointing!…

Please follow and like us:
0

LEAVE A REPLY

Please enter your comment!
Please enter your name here