尝试列出所有已发布的已发布页面库中的页面。使用以下代码我会检查并检出页面。如何仅过滤掉已签入的页面?
SPList pageList = web.Lists["Pages"];
DataTable dtNews = getNewsTable();
foreach (SPListItem item in pageList.Items)
{
if (item.ContentType.Name == "Article Page")
{
var publishingPage = PublishingPage.GetPublishingPage(item);
}
}
答案 0 :(得分:2)
试试这个:
SPList pageList = web.Lists["Pages"];
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='CheckoutUser' LookupId='TRUE'/><Value Type='int'>0</Value></Eq></Where>";
foreach (SPListItem item in pageList.GetItems(query))
{
if (item.ContentType.Name == "Article Page")
{
var publishingPage = PublishingPage.GetPublishingPage(item);
}
}
答案 1 :(得分:0)
检查文件未签出而不是草稿
foreach (SPListItem item in pageList.Items)
{
if (item.ContentType.Name == "Article Page")
{
SPFile file = item.File;
if (file.Level != SPFileLevel.Draft && file.Level != SPFileLevel.Checkout)
{
}
}
}