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 > 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>
<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 > 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>
Nice one. Now how to scroll horizontally?
Hi there,
You need to change the marquee element to what you would like.
I changed the sample to: direction="right"
this is nice. how do you change the scroll speed?
thanks
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
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.
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.
@jsharetech
to change the speed, alter the values in the line:
<marquee direction="left" onMouseover="this.scrollAmount=2" onMouseout="this.scrollAmount=6">
0 = stop scrolling
100 = very very fast!