以编程方式签入页面库中的发布页面
Programmatically Get Checked In publishing pages from pages library
我正在尝试列出页面库中所有发布签入的页面。使用以下代码获取签入和签出页面。如何过滤掉仅签入的页面?
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);
}
}
试试这个:
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);
}
}
正在检查文件未签出且不在草稿中
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)
{
}
}
}
我正在尝试列出页面库中所有发布签入的页面。使用以下代码获取签入和签出页面。如何过滤掉仅签入的页面?
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);
}
}
试试这个:
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);
}
}
正在检查文件未签出且不在草稿中
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)
{
}
}
}