Welcome to MSDN Blogs Sign in | Join | Help

Team Individualism

Optimised technology investigated

News

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="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl ddwrt msxsl" 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:output method="html" indent="no"/>

<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://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 &gt; 0">font-weight:Bold;</xsl:if>
<xsl:if test="@Italics &gt; 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>

Posted: Tuesday, October 03, 2006 2:56 PM by drmcghee

Comments

Hitman322 said:

Nice one. Now how to scroll horizontally?

# June 23, 2008 1:02 PM

drmcghee said:

Hi there,

You need to change the marquee element to what you would like.

I changed the sample to: direction="right"

# October 31, 2008 6:39 PM

jsharetech said:

this is nice. how do you change the scroll speed?

thanks

# November 20, 2008 3:46 PM

mbiker said:

Hi. Does it work with WSS3.0? I've found the XML Web Part and pasted the code into the XML Editor text area. I should change the <xsl:variable name="Rows" select="/rss/channel/item"/> line isn't it? Could you give me an example please?

Thanks

# November 27, 2008 7:32 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker