The WorkerThread Blog

we know stuff so you don't have to

SharePoint 2010 RSS Viewer Web Part Tip and Question

Posted by workerthread on December 10, 2010

Here’s a quick tip you may want to use if you are working with the RSS Viewer web part in SharePoint 2010 and want to open articles in an new window – also a quick question I would appreciate any comments on.

The RSS Viewer web part is a good way of adding interesting content to SharePoint site home pages.  There are lots of good quality RSS feeds out there – for example BBC News, various Microsoft Technical resources and many diverse trade publications (or even this blog).   It’s pretty easy to set up once you have chosen a useful feed.  Here’s an example which has been configured to use the TechNet News feed:

RSSFeed1

Clicking on an article heading will reveal some more detail:

RSSFeed2

Then if you then click on the “More…” link, you will open the source article in the current window.  Now, I’ve found this is not always ideal and you often want to open the article in a new window, without leaving your SharePoint site page.  To make this happen, it’s necessary to make a change to the “More…” hyperlink.  You do this by editing the web part and clicking on the XSL Editor button to open the text editor:

XSLEditor

This exposes the XSL styles which define how the RSS feed is displayed (if you’re looking for XSL syntax info by the way, take a look online for articles by Marc D. Anderson – he’s published some excellent stuff).

One particular line is of interest to us.  It’s in the section “RSSMainTemplate.description” and is the line defining the “href” tag to open the article when clicking on “More…”:

<a href=”{ddwrt:EnsureAllowedProtocol(string(atom2:link/@href))}”>More…</a>

To make the article open in a new window, you need to add a target=”_blank” attribute like so:

<a href=”{ddwrt:EnsureAllowedProtocol(string(atom2:link/@href))}” target=”_blank”>More…</a>

(by the way I prefer to copy the entire XSL into a better text editor to make my changes, then paste the whole lot back into the web part XSL Editor afterwards rather than working in the web part editor)

Once you’ve done that, apply your changes and you will find that your RSS feed articles will open in a new window when you click on the More… link.

And so to My Question –

In some circumstances I’ve noticed there can sometimes be problems with the RSS Viewer web part loading correctly – it seems to get stuck in “Loading” mode without ever completing.  I’ve checked around to see if anyone else is experiencing this with SharePoint 2010 but haven’t found any definitive information.  There’s a school of thought that this could occur when Alternate Access Mappings have been set up for the web application, although I’m not sure why this would be.  So if anyone can shed light on this please leave a comment!

Technorati Tags: ,,
Advertisements

4 Responses to “SharePoint 2010 RSS Viewer Web Part Tip and Question”

  1. Ahmed M. Gamil said

    Now, I’ve tried to do the same but when I edit XSLT using the editor the changes are not reflected and the “More…” link still opens in the same page, so I’ve tried to check something so I’ve changed more to “More……..” and again it was the same the “more” part appeared without any change. Looks like the XSLT is not affecting the RSS Viewer.

    Please, help..

  2. Ahmed M. Gamil said

    OK.. I’ve found the solution 🙂 .. All I needed to do is to copy-paste the XSLT code into a note pad and modify it then copy-pasting it again into the editor and everything went fine. Many thanks for the article. It was very helpful.

  3. ryan said

    I am trying to modify the XSL so that my RSS web part shows the Title and PubDate and sorts the items by PubDate but I can’t figure it out. Been at it for 2 days with no luck. Anybody care to post up the XSL code I need?

  4. I have the same problem with getting stuck in “Loading” mode. 😦

Sorry, the comment form is closed at this time.

 
%d bloggers like this: