Ich verwende den HillBilly-Schieberegler für eine meiner Websites. Es funktioniert gut, aber ich wollte auch das Titelfeld im Slider verwenden. Ich habe den Code angepasst, aber wo der Titel sein soll, bekomme ich einfach "Undefined". Soweit ich das beurteilen kann, ist der Code korrekt. Kann jemand meinen Code ansehen, um zu sehen, wo ich versagt habe?SharePoint 2010 Anpassen der CAML-Abfrage
Dank
<style type="text/css">
.hillbillyBanner { position: relative; overflow: auto; }
.hillbillyBanner li { list-style: none; }
.hillbillyBanner ul li { float: left; height: 200px; width: auto;}
.hillbillyBanner ul {margin-left: -40px;}
p {margin-left: 25px;}
h2 {margin-left: 15px;}
</style>
<script type="text/javascript">
jQuery(document).ready(function($) {
var sliderList = "Announcements";// Name of the list that contains slides
var slideTitleField = "Title";
var slideContentField = "Body"; //Name of the Rich text field that has slide content
var slideBackgroundImageField = "Image"; //Name of the picture field to use as background image
HillbillySlider(sliderList,slideTitleField,slideContentField,slideBackgroundImageField);
});
function HillbillySlider(sliderList,slideTitleField,slideContentField,slideBackgroundImageField) {
//query to retrieve all items
var query = "<Query><Where><And><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq><Eq><FieldRef Name='Active' /><Value Type='Boolean'>1</Value></Eq></And></Where></Query>";
//return fields for slide content and background picture
var camlViewFields = "<ViewFields><FieldRef Name='"+slideTitleField+"' /><FieldRef Name='"+slideContentField+"' /><FieldRef Name='"+slideBackgroundImageField+"' /></ViewFields>";
$().SPServices({
operation: "GetListItems",
async: true,
listName: sliderList,
CAMLViewFields: camlViewFields,
CAMLQuery: query,
completefunc: function(xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var slideTitleField = ($(this).attr("ows_"+slideTitleField));
var slideContent = ($(this).attr("ows_"+slideContentField));
var picture = $(this).attr("ows_"+slideBackgroundImageField)==undefined?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0];
//create slide (li) and append it to other slides
$("#hillbillySlider").append("<li style=\"background-image: url('"+picture +"');\"><h2>"+slideTitleField+"</h2><p>"+slideContent+"</p></li>");
}); // end completefunc
//start the slider
$('.hillbillyBanner').unslider();
}
}); // end SPServices call`enter code here`
}
</script>