<script type="text/javascript">
$(document).ready(function () {
var camlQuery = "<Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>MitieNewsArticle</Value></Eq></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query>";
var count=0;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Pages",
CAMLViewFields: '<ViewFields><FieldRef Name=\"EncodedAbsUrl\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"FileLeafRef\" /><FieldRef Name=\"HomePageText\" /><FieldRef Name=\"PublishingRollupImage\" /></ViewFields>',
CAMLQuery: camlQuery,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
count=count+1;
if(count==1){
var article1Introduction=TruncateArticle1($(this).attr("ows_HomePageText"));
var article1URL=$(this).attr("ows_EncodedAbsUrl");
var article1html = "<div class='text-indent'> <p>"+article1Introduction+"</p><div class='arrow show-Mobile'>.</div><a href='"+ article1URL + "'> Read More </a></div>";
article1html =article1html + "<div class='image-indent'>" + $(this).attr("ows_PublishingRollupImage") +"</div>";
$("#article1Content").html(article1html );
}
});
}
});
});
function TruncateArticle1(text) {
var length = 132;
var ellipsis = '...';
if (text.length < length) return text;
for (var i = length - 1; text.charAt(i) != ' '; i--) {
length--;
}
return text.substr(0, length) + ellipsis;
}
</script>
<div id="article1Content"></div>
$(document).ready(function () {
var camlQuery = "<Query><Where><Eq><FieldRef Name='ContentType' /><Value Type='Computed'>MitieNewsArticle</Value></Eq></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query>";
var count=0;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Pages",
CAMLViewFields: '<ViewFields><FieldRef Name=\"EncodedAbsUrl\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"FileLeafRef\" /><FieldRef Name=\"HomePageText\" /><FieldRef Name=\"PublishingRollupImage\" /></ViewFields>',
CAMLQuery: camlQuery,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
count=count+1;
if(count==1){
var article1Introduction=TruncateArticle1($(this).attr("ows_HomePageText"));
var article1URL=$(this).attr("ows_EncodedAbsUrl");
var article1html = "<div class='text-indent'> <p>"+article1Introduction+"</p><div class='arrow show-Mobile'>.</div><a href='"+ article1URL + "'> Read More </a></div>";
article1html =article1html + "<div class='image-indent'>" + $(this).attr("ows_PublishingRollupImage") +"</div>";
$("#article1Content").html(article1html );
}
});
}
});
});
function TruncateArticle1(text) {
var length = 132;
var ellipsis = '...';
if (text.length < length) return text;
for (var i = length - 1; text.charAt(i) != ' '; i--) {
length--;
}
return text.substr(0, length) + ellipsis;
}
</script>
<div id="article1Content"></div>
No comments:
Post a Comment