November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I think you'll need to clear the cache for the page after saving it:
DataFactoryCache.RemovePage(writablePage)
After adding this line. Following happens
1:- If page has no changes to publish. the changes i made in back end displayed properly
2: If page has already some changes which are pending to be published then changes made in backend are still not visible in site pages
I'm guessing you'll need to fetch the latest version when programmatically getting the page:
var repository = ServiceLocator.Current.GetInstance<IContentVersionRepository>(); var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); var latestVersion = repository.List(page.ContentLink).OrderBy(x => x.Saved).FirstOrDefault(); var latestPage = contentLoader.Get<PageData>(latestVersion.ContentLink); var writablePage = (latestPage as PageData).CreateWritableClone(); latestPage.Name = "new name!";
I did not test this though. The OrderBy might need to reversed :-)
but that will give me last saved version of the page and all my changes will reflect in that version. i want to create new version of programatic changes for that page.
Then I suppose you need to set the common draft to the new version you create:
writablePage.Name = "a new name"; var saveAction = SaveAction.CheckIn | SaveAction.ForceNewVersion; var newReference = contentRepository.Save(writablePage, saveAction, EPiServer.Security.AccessLevel.NoAccess); var repository = ServiceLocator.Current.GetInstance<IContentVersionRepository>(); repository.SetCommonDraft(newReference);
Thanks aloooooot!!! Now its working fine
Only last question is if use following Save Action, the page changes do not appear in "Drafts" category of Tasks gadget
var saveAction = SaveAction.Save
Are you sure you refreshed the gadget? It should appear if you use "SaveAction.Save".
yes i have refreshed the gadget and i have refreshed the page but gadget is nt displaying but again if i do some manual change, it starts appearing in Gadget
yes in the versions gadget it shows this version status as draft with three nested circles on on right top corner of this column
Okay, then it should be working. Are you sure it's not just out of sight? If you scroll down? :-)
Or do you see it if you select something other than "draft"? Like "ready to publish"?
if i use SaveAction.CheckedIn then it appears under Ready to publish catgory but if i use SaveAction.Save it doesnot appear under Draft or any other categorie.
I have doubled checked the scrol bar thing but its not there :-(
In the versions list, who does it say that the page has been saved by? System? Cause "tasks" will only display content changed by you
I m setting the changedby in backend
writablePage.ChangedBy = "BackEndUser";
BackEndUser is different from the one i am using to log into Epi Server cms
Versions gadget shows saved by "BackEndUser"
how can make it viewable for tasks gadget of any editor who has the publishing rights?????
Hi, Yasar,
I ended up using a different value for ChangedBy, check out this blog post:
However, what is different in later version of 8 is the following:
So, now, instead of using SaveAction.Save | SaveAction.ForceCurrentVersion, I use SaveAction.Publish | SaveAction.SkipSetCommonDraft.
Then, in the published event, I check the save action:
if (e.Content is IHasFeedback && e.Content is IChangeTrackable && ((SaveContentEventArgs)e).Action != AppSettings.SaveActionForNonContentChanges) { ((IHasFeedback)e.Content).RealContentChangedBy = ((IChangeTrackable)e.Content).ChangedBy; }
We didn't have any issues with the approach so far.
i m using epi server 8 and I am editing page programatically but changes made programatically does not show up in site pages in order for editor to publish publish but when i check the page history it shows changes over there
my code is
var pages = DataFactory.Instance.FindAllPagesWithCriteria(PageReference.StartPage, Criterias, "en", new LanguageSelector("en"));
if (pages != null && pages.Count > 0)
{
var Page = pages[0];
writablePage = (Page as PageData).CreateWritableClone();
writablePage.Name = (writablePage as MyPage).PageTitle = "Page Name";
var saveAction = SaveAction.CheckIn | SaveAction.ForceNewVersion;
DataFactory.Instance.Save(writablePage, saveAction, EPiServer.Security.AccessLevel.NoAccess);
}