Sharepoint RSS ticker
One of the MOSS 2007 SharePoint web parts is an RSS or XML web part which can take XML content and transform it. Making a new ticker was tricky in 2003, though there was a nice solution I found here.
In the new web part you can use this code to display a simple HTML marquee element based on the RSS content found:
<xsl:stylesheet xmlns:x="https://www.w3.org/2001/XMLSchema" xmlns:d="https://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl ddwrt msxsl" xmlns:ddwrt="https://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="https://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="html" indent="no"/><xsl:template match="/" xmlns:x="https://www.w3.org/2001/XMLSchema" xmlns:d="https://schemas.microsoft.com/sharepoint/dsp">
<xsl:call-template name="ticker"/>
</xsl:template><xsl:template name="ticker">
<xsl:variable name="StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/rss/channel/item"/>
<xsl:variable name="RowCount" select="count($Rows)"/>
<xsl:variable name="IsEmpty" select="$RowCount = 0"/>
<xsl:choose>
<xsl:when test="$IsEmpty">
<xsl:call-template name="empty"/>
</xsl:when>
<xsl:otherwise><table border="0" width="100%" cellpadding="2" cellspacing="0" class="ms-nav">
<tr>
<td class="ms-vb"><marquee direction="right" onMouseover="this.scrollAmount=2" onMouseout="this.scrollAmount=6">
<xsl:call-template name="tickerBody">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="FirstRow" select="1"/>
<xsl:with-param name="LastRow" select="$RowCount"/>
</xsl:call-template>
</marquee></td>
</tr>
</table></xsl:otherwise>
</xsl:choose>
</xsl:template><xsl:template name="tickerBody">
<xsl:param name="Rows"/>
<xsl:param name="FirstRow"/>
<xsl:param name="LastRow"/>
<xsl:variable name="GroupStyle" select="'auto'"/><xsl:for-each select="$Rows">
<!-- insert your own preferred image here -->
<img src="_layouts/images/navlink.gif" mce_src="_layouts/images/navlink.gif" border="0"/>
<img src="_layouts/images/blank.gif" mce_src="_layouts/images/blank.gif" height="1" width="10" alt="Icon" border="0"/>
<a style="display:{$GroupStyle}">
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<font>
<!-- change this to have a fixed style
<xsl:attribute name="size">
<xsl:value-of select="@Font_x0020_Size"/>
</xsl:attribute>
<xsl:attribute name="style">
<xsl:if test="@Bold > 0">font-weight:Bold;</xsl:if>
<xsl:if test="@Italics > 0">font-style:Italic;</xsl:if>
</xsl:attribute>
<xsl:attribute name="color">
<xsl:value-of select="@Color"/>
</xsl:attribute>-->
<xsl:value-of select="title"/>
</font>
</a>
<img src="_layouts/images/blank.gif" mce_src="_layouts/images/blank.gif" height="1" width="20" alt="Icon" border="0"/>
<!-- add this line below for up marquee
<br/>
-->
</xsl:for-each>
</xsl:template><xsl:template name="empty">
<xsl:variable name="ViewEmptyText">There are no current announcements.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$ViewEmptyText"/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Comments
Anonymous
June 23, 2008
Nice one. Now how to scroll horizontally?Anonymous
October 31, 2008
Hi there, You need to change the marquee element to what you would like. I changed the sample to: direction="right"Anonymous
November 20, 2008
this is nice. how do you change the scroll speed? thanksAnonymous
November 26, 2008
The comment has been removedAnonymous
December 14, 2009
I am looking for something like this but does this code works with external RSS feeds? Or only internal feeds? And where in the code should I place the location of the feed? Thanks in advance.Anonymous
July 18, 2010
Goto into Sharepoint, add a RSS webpart, edit the webpart and add your feed into the RSS Feed URL. Then click on the XSL editor and paste the above code.Anonymous
July 29, 2010
The comment has been removedAnonymous
February 09, 2015
Good afternoon, This code works great and I have the ticker tape running across the top of the page! I am not familiar with XML however and would like to ask how I change the background to white or transparent and the font to dark grey, Verdana 11. Thank you.Anonymous
March 09, 2015
Hi there, How can I change the font and background color of the RSS newsfeed within the webpart?Anonymous
March 11, 2015
This is great but the scroll starts over as soon as it reaches the left border. How Do I keep it scrolling all the way through the RSS feed list?