Sharepoint 2010 SharePoint 2010调整CAML查询
我正在为我的一个网站使用HillBilly滑块。它的工作非常好,但我还想使用滑块中的标题字段。我调整了代码,但是在标题应该是的地方,我只得到了“未定义”。据我所知,代码是正确的。有人能看看我的代码,看看我在哪里搞砸了吗 谢谢Sharepoint 2010 SharePoint 2010调整CAML查询,sharepoint-2010,slider,caml,Sharepoint 2010,Slider,Caml,我正在为我的一个网站使用HillBilly滑块。它的工作非常好,但我还想使用滑块中的标题字段。我调整了代码,但是在标题应该是的地方,我只得到了“未定义”。据我所知,代码是正确的。有人能看看我的代码,看看我在哪里搞砸了吗 谢谢 <style type="text/css"> .hillbillyBanner { position: relative; overflow: auto; } .hillbillyBanner li { list-style: none; } .hillb
<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>
.hillbillyBanner{position:relative;overflow:auto;}
.hillbillyBanner li{列表样式:无;}
.hillbillyBanner ul li{浮点:左;高度:200px;宽度:自动;}
.hillbillyBanner ul{左边距:-40px;}
p{左边距:25px;}
h2{左边距:15px;}
jQuery(文档).ready(函数($){
var sliderList=“Announcements”;//包含幻灯片的列表的名称
var slideTitleField=“Title”;
var slideContentField=“Body”;//包含幻灯片内容的富文本字段的名称
var slideBackgroundImageField=“Image”//要用作背景图像的图片字段的名称
HillbillySlider(sliderList、slideTitleField、slideContentField、slideBackgroundImageField);
});
函数HillbillySlider(sliderList、slideTitleField、slideContentField、slideBackgroundImageField){
//查询以检索所有项目
var query=“1”;
//幻灯片内容和背景图片的返回字段
var camlViewFields=“”;
$().SPServices({
操作:“GetListItems”,
async:true,
listName:sliderList,
CAMLViewFields:CAMLViewFields,
CAMLQuery:query,
completefunc:函数(扩展数据、状态){
$(扩展数据.responseXML).SPFilterNode(“z:row”).each(函数(){
var slideTitleField=($(this.attr)(“ows_”+slideTitleField));
var slideContent=($(this.attr(“ows_”+slideContentField));
var picture=$(this.attr(“ows_“+slideBackgroundImageField)==未定义?”:$(this.attr(“ows_“+slideBackgroundImageField”)。拆分(“,”[0];
//创建幻灯片(li)并将其附加到其他幻灯片
$(“#hillbillySlider”).append(““+slideTitleField+”“+slideContent+””);
});//结束completefunc
//启动滑块
$('.hillbillyBanner').unslider();
}
});//结束SPServices调用`在此处输入代码`
}
啊找到了答案我不小心设置了两次标题变量,结果它自己取消了
那么这个
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>");
var slideTitleField=($(this.attr)(“ows_”+slideTitleField));
var slideContent=($(this.attr(“ows_”+slideContentField));
var picture=$(this.attr(“ows_“+slideBackgroundImageField)==未定义?”:$(this.attr(“ows_“+slideBackgroundImageField”)。拆分(“,”[0];
//创建幻灯片(li)并将其附加到其他幻灯片
$(“#hillbillySlider”).append(““+slideTitleField+”“+slideContent+””);
更改为:
var slideTitle = ($(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 +"'); background-repeat: no-repeat;\"><h2>"+slideTitleField+"</h2><p>"+slideContent+"</p></li>");
var-slideTitle=($(this.attr)(“ows_”+slideTitleField));
var slideContent=($(this.attr(“ows_”+slideContentField));
var picture=$(this.attr(“ows_“+slideBackgroundImageField)==未定义?”:$(this.attr(“ows_“+slideBackgroundImageField”)。拆分(“,”[0];
//创建幻灯片(li)并将其附加到其他幻灯片
$(“#hillbillySlider”).append(“”+slideTitleField+“”+slideContent+“ ”);