Tags

,

By using Scott Price’s code, I add a query to the CAML so it will only display annoucment which not expired.

<script type="text/javascript" src="/Development Library/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="/Development Library/jquery.newsticker.js"></script>
<script type="text/javascript" src="/Development Library/DateUtilities.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
	var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"; 
		soapEnv += "<listName>Announcements</listName>"; 
		soapEnv += "<query><Query><Where><Geq><FieldRef Name='Expires' /><Value Type='DateTime'><Today/></Value></Geq></Where></Query></query>"; 
		soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='Created'/><FieldRef Name='ID'/></ViewFields></viewFields>"; //<RowLimit>1</RowLimit>
		soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

        $.ajax({
            url: "../_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    });

function processResult(xData, status) {        
        var newnews = $("<ul>").attr("class", "newsticker");
        var rows;
        if (xData.responseXML.getElementsByTagName("z:row").length==0)
        {
			var url = "/test/Lists/Announcements/";
            var liHtml = "<li class='newscontent'> <b> No Latest News <br><br><a href='" + url + "'>Read All"+"</a></b></li>";
            newnews.append(liHtml);
        }
        else
        {
			rows = xData.responseXML.getElementsByTagName("z:row");
			jQuery(rows).each(function() {
            var createdDate= $(this).attr("ows_Created").split(" ");
            var url = "/test/Lists/Announcements/DispForm.aspx?ID=" + $(this).attr("ows_ID");
            createdDate = parseDate(createdDate[0]);
            var liHtml = "<li class='newscontent'>" +  formatDate(createdDate ,'dd MMM yy')+ " - <b>" +  $(this).attr("ows_Title")+ "<br><br><a href='" + url + "'>Read Details"+"</a></b></li>";
            newnews.append(liHtml);
        });
        }
        
        

        newnews.appendTo("#tasksUL").newsTicker();
    }
</script>

<style type="text/css">
.newsticker {
list-style-type: none;
height:50px;
color:#336699;
margin-top: 10;
}

.newscontent{
list-style-type: none;
margin-left: 0;
display: inline;

}

.news{
background: url(/_layouts/1033/IMAGES/SIMCENTRAL/link_m.gif) no-repeat  scroll center top;
width:240px;
}

.marktop {
background:transparent url(/_layouts/1033/IMAGES/SIMCENTRAL/link_t.gif) no-repeat scroll center top;
height:11px;

padding:0;
width:240px;
}

.markbottom {
background:transparent url(/_layouts/1033/IMAGES/SIMCENTRAL/link_b.gif) no-repeat scroll center top;
height:11px;
margin-left:0;
padding:0;
width:240px;
}
.markcenter {
height:auto;
margin-top:10;
padding:0;
width:211px;
}
</style>
<div class="markcenter">
<div class="marktop"/>
<div class="news">
<br>
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Noticeboard</b>
<div id="tasksUL" 
</div> 
</div>
<div class="markbottom"/>
</div>


Advertisements