SaaS CMS has officially launched! Learn more now.

Get latest page version (saved, not published)




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?

Jan 31, 2014 13:15

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.

Feb 01, 2014 22:51

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.

Feb 02, 2014 23:23

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?

Feb 03, 2014 11:23

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.

Feb 03, 2014 11:28

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!

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.