Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Get latest page version (saved, not published)

Vote:
 

Hello,

 

We are currently working on something which saves changes to pages. The user then needs to be able to publish these changes later. Publishing is easy with the Save method in the content repository, the problem is I can't figure out how to get the pages in their latest saved version to then publish those changes.

 

Any calls to Get or GetChildren only get me the latest published version of the page. How can I get the absolute latest version, which may not be published?

#80767
Jan 31, 2014 13:15
Vote:
 

You can try to play around with content version repository.

var repository = ServiceLocator.Current.GetInstance<IContentVersionRepository>();
// enlists all available versions
var versions = repository.List(pageReference);

    

In the list of available versions you may try to order by saved date to get latest "valid" draft.

#80784
Feb 01, 2014 22:51
Vote:
 

Getting the latest version of several pages might use alot of performance. I'd suggest that you cache your result.

Note that you can create dependencies to content in EPiServer by using DataFactoryCache.CreateDependency(ContentReference) so when you update that specific page, your cache will be invalidated.

#80794
Feb 02, 2014 23:23
Vote:
 

Thanks! That content version repository looks almost exactly what I am looking for, however I'm having issues actually getting the PageData for a given version.

I can get the latest version by using the Status and Saved properties, but once I have it I don't know what I can do to get to that version's page properties?

#80811
Feb 03, 2014 11:23
Vote:
 

Each ContentVersion contains a ContentLink that is a ContentReference, containing the version number.

You can use that to get the Content as any other ContentReference.

#80812
Feb 03, 2014 11:28
Vote:
 

Ah right ok, I saw the ContentLink on the object but I didn't realise it was actually associated with the version.

That should work great, thanks!

#80814
Feb 03, 2014 11:41
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.