how to publish a PageDraft and have it appear in revision history
I'm trying to work out how to properly republish a page.
We need to do this accross all pages on the site (corporate Intranet - approx 1900 migrated pages from 3.7 --> 4.1)
an issue we discovered is that the migrated pages show NOTHING in revision history until they are edited and published again (i raised this as an issue into PITS previously). we believe this is behind a few different issues we are trying to work through, for example they can't be unpublished in this state.
I have created new clean 4.1 site with 6 pages, in an effort to work out how to do this correcly.
I am trying as follows:
public
static
string
RepublishAllPages()
string
result =
""
;
var pageNodes = App.WorkWith()
.Pages()
.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Get()
.Where(pN => pN.Page.Status == ContentLifecycleStatus.Live)
.ToList();
foreach
(PageNode p
in
pageNodes)
var myId = p.Page.Id;
var myDraft = m_PageManager.EditPage(myId,
true
);
m_PageManager.PublishPageDraft(myDraft,
true
);
result += p.Page.Title +
" published"
;
m_PageManager.SaveChanges();
return
result;
Hi Justin,
We have replied to you in the support thread you have opened. You can check my reply there, but for your convenience I'll also paste it below:
"
To create revision history of your page you can either CheckIut and then CheckIn the page (which will create a new draft version of the page, newer thatn the published version) or use the version manager and create a version directly. Please find an example of working with the version manager in this forum thread. Concerning the creation of a newer than published draft version, you can use use the below code sample:
var myPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.Where(pG =>
pG.Page != null
&& pG.Page.Status == ContentLifecycleStatus.Live
&& pG.Page.Title == "Home")
.Get()
.ToList();
foreach(var p inmyPages)
App.WorkWith().Page(p)
.AsStandardPage()
.CheckOut()
.Do(pag =>
pag.LastModified = DateTime.UtcNow;
)
.CheckIn()
.SaveAndContinue()
.SaveChanges();
Boyan,
I am struggling a little bit with some code. I hope you can help me. At the moment Sitefinity does nto offer a feature where I can specify how many revisions of a page I want to keep. Therefore, I am trying to implement a mechanism through a WebService where:
1 - I get a list of pages that have more than lets say 1000 revisions,
2 - Then for each of those pages, I delete revisions that are older than lets say 6 months.
The first problem that I am getting is that it is complaining about 'pG' not being declared.
Dim myPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).Where(pG >= pG.Page IsNot Nothing And pG.Page.RevisionCount >= 1000).Get().ToList()
Looks like a syntax error in your where clause?
Thanks Justin, I knew that. It automatically changes it round for some reason. Because it does not interpret pG properly, it swaps it round thinking that pG is a number or something.
Hi, I dont need anymore help here. I took a different approach which seems to be fine. I am doing it via a Custom Module, which seems to have all teh references sorted.
Many thanks