好的,爲了解決這個問題,你需要在你的站點安裝jQuery 1.7.x +和SPServices jQuery library版本0.7.2或更高版本。使用GetListItems作爲來自SPServices的操作。
我正在尋找Pages目錄內的頁面,所以listName是「Pages」。
CAML視圖字段基本上是PublishingContactEmail和PublishingContact的列。我發現那些使用u2u's CAML builder version 4.0.0.0
ows_變量可以在螢火蟲的POST對象的xml視圖中找到。
ows_PublishingContact返回一個長長的討厭的聯繫人信息字符串。幸運的是,電子郵件地址被,#
包圍,這使得它分成數組,然後搜索email @ easy,但這就是爲什麼在那裏。
function get_page_contact_email() {
var thisPageID = _spPageContextInfo.pageItemId;
var e;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Pages",
CAMLViewFields: "<ViewFields><FieldRef Name='PublishingContactEmail' /><FieldRef Name='PublishingContact' /></ViewFields>",
CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
if (thisPageID == $(this).attr("ows_ID")) {
if ($(this).attr("ows_PublishingContactEmail")) { // if page email is set
e = $(this).attr("ows_PublishingContactEmail");
} else if ($(this).attr("ows_PublishingContact")) { //otherwise use contact info
var contact = $(this).attr("ows_PublishingContact").split(",#");
for (var c = 0; c < contact.length; c++) {
if (contact[c].indexOf("@") != -1) {
e = contact[c];
}
}
} else { //or nothing is set.
e = false;
}
}
});
}
});
return e;
}