How do you find unpublished pages based on criteria?

Vote:
 

It appears that EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentVersionRepository>().LoadCommonDraft is returning published and unpublished pages based on a supplied ContentLink. How do I return only unpublished pages?

var draftRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentVersionRepository>();
            ContentVersion draftPage = draftRepository.LoadCommonDraft(contentLink:MyContentLink, language: Language.Name);

#81259
Feb 12, 2014 21:51
Vote:
 

If the content will not have a common draft, published version will be returned. Check whether page really contains common draft. If there is no publish content - last saved version is returned.

If you want to check what you got back you should look for Status property of ContentVersion type.

#81261
Feb 12, 2014 23:43
Vote:
 

Hi,

You can use one of these:

IEnumerable<ContentVersion> List(ContentReference contentLink);
IEnumerable<ContentVersion> List(ContentReference contentLink, string languageBranch);

then filter out:

Where(v => v.Status != VersionStatus.Published)

Regards.

/Q

#81266
Feb 13, 2014 5:09
Vote:
 

Thanks. I've added a check to see if it is the Common Draft and CheckedIn.

Do I still need to make a CreateWritableClone if I want to save the page again?

 

if (draftPage.IsCommonDraft && draftPage.Status == VersionStatus.CheckedIn)

#81305
Feb 13, 2014 17:41
Vote:
 

Yes, you still need to make a CreateWritableClone if you want to modify the instance.

/Q

#81311
Feb 14, 2014 1:27
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.