I created a news list in SharePoint 2010 that shows news on the home page just like a news ticker with JavaScript. I used a content query web part to show news. This article is so useful, but doesn't work. Maybe I'm wrong.
I modified page.aspx
containing CQWP, ItemStyle.aspx
, and ContentQueryMain.aspx
in SharePoint Designer 2010. I downloaded JavaScript news ticker and uploaded it to the All Files folder. I did these steps to show news:
1- Added to page header that contains CQWP:
<link href="css/ticker-style.css" rel="stylesheet" type="text/css" />
<script src="jquery.ticker.js" type="text/javascript"></script>
2- Added link reference to master page head:
<script type="text/javascript" src="../../jquery_news_ticker/includes/jquery.ticker.js"></script>
<script type="text/css" src="../../jquery_news_ticker/styles/ticker-style.css"></script>
3- Modified itemstyle:
<xsl:template name="simpleRowAndTitle" match="Row[@Style='simpleRowAndTitle']" mode="itemstyle">
<xsl:param name="CurPos" />
<div class="item">
<span><xsl:value-of select="$CurPos" /></span>
<xsl:value-of select="@Title"/>
</div>
</xsl:template>
4- Modifed ContentByQueryMain.xsl
:
In ContentByQueryMain.xsl
search for the template "OuterTemplate.CallItemTemplate". This should contain an xsl choose statement. Find the "otherwise" part that looks similar to the below block:
<xsl:otherwise>
<xsl:apply-templates select="." mode="itemstyle">
<xsl:with-param name="CurPos" select="$CurPosition" />
</xsl:apply-templates>
</xsl:otherwise>
5- Finally create template ticker:
<xsl:template name="ticker" match="Row[@Style='ticker']" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$CurPos='1' ">
<xsl:variable name="JScript">
<![CDATA[
$(document).ready(function(){
$('.ticker-news-item').each(function(){
var newItemString = "<li class='news-item'>" + $(this).html()+ "</li>";
$('#js-news').append(newItemString);
$(this).remove();
});
$('#js-news').ticker({ });
});
]]>
</xsl:variable>
<script type='text/javascript'>
<xsl:value-of select="$JScript" disable-output-escaping="yes"/>
</script>
<div id="ticker-wrapper" class="no-js">
<ul id="js-news" class="js-hidden"></ul>
</div>
</xsl:if>
<div class='ticker-news-item' >
<a href='{$SafeLinkUrl}' target='_blank'>
<xsl:value-of select="@Title" />
</a>
</div>
</xsl:template>
6- Apply this template on CQWP:
After these steps nothing changes.