Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
// We want to replace the currently published version. To do
// that, we need to make sure we load that specific version
// (just the page ID will not be enough.)
PageReference pageRef = new PageReference(id);
PageVersion pubVer = PageVersion.LoadPublishedVersion(pageRef);
// if no published version exists, we wont save.
if (pubVer == null)
break;
PageReference pubRef = pubVer.ID;
PageData page = Global.EPDataFactory.GetPage(pubRef);
... do things with the page here
SaveAction action = SaveAction.None;
if (page.CheckPublishedStatus(PagePublishedStatus.Ignore))
action = SaveAction.Publish;
else
action = SaveAction.Save;
// Do not create a new version
action = action | SaveAction.ForceCurrentVersion;
// Save the page
Global.EPDataFactory.Save(page, action);