Guid currentSiteGuid = SPContext.Current.Site.ID;
using (SPSite site = new SPSite(currentSiteGuid))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
PublishingPageCollection pages = publishingWeb.GetPublishingPages();
foreach (PublishingPage page in pages)
{
SPFile file = web.GetFile(web.Url + "/" + page.Url);
file.CheckOut();
if (page.Name == "AdministratorInformation.aspx")
{
page.Title = "Administrator Information";
page.Update();
}
else if (page.Name == "AdministratorPage.aspx")
{
page.Title = "Administrator Page";
page.Update();
}
else
{
page.Title = "";
}
file.CheckIn("pagename");
file.Publish("Publish");
file.Approve("Approve");
file.Update();
//Including Pages in current Navigation
publishingWeb.IncludeInNavigation(true, page.ListItem.UniqueId);
publishingWeb.ExcludeFromNavigation(true, page.ListItem.UniqueId);
}
publishingWeb.Update();
web.Update();
web.AllowUnsafeUpdates = false;
}
}
using (SPSite site = new SPSite(currentSiteGuid))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
PublishingPageCollection pages = publishingWeb.GetPublishingPages();
foreach (PublishingPage page in pages)
{
SPFile file = web.GetFile(web.Url + "/" + page.Url);
file.CheckOut();
if (page.Name == "AdministratorInformation.aspx")
{
page.Title = "Administrator Information";
page.Update();
}
else if (page.Name == "AdministratorPage.aspx")
{
page.Title = "Administrator Page";
page.Update();
}
else
{
page.Title = "";
}
file.CheckIn("pagename");
file.Publish("Publish");
file.Approve("Approve");
file.Update();
//Including Pages in current Navigation
publishingWeb.IncludeInNavigation(true, page.ListItem.UniqueId);
publishingWeb.ExcludeFromNavigation(true, page.ListItem.UniqueId);
}
publishingWeb.Update();
web.Update();
web.AllowUnsafeUpdates = false;
}
}
No comments:
Post a Comment