November Happy Hour will be moved to Thursday December 5th.

FindPagesWithCriteria and pages pending publish

Vote:
 
Hi there We're having trouble getting DataFactory.Instance.FindPagesWithCriteria to return pages that has not been published. Is it at all possible to get this function to find both published and unpublished pages?? We have tried to add a PropertyCriteria, with the name "PendingPublish" and value true, to the criteria collection and hoped that would solve the problem but it didn't.
#13334
Jan 24, 2008 13:17
Vote:
 
Adding a PropertyCriteria will not help: FindPagesWithCriteria will only return pages that are published!
#15607
Jan 28, 2008 14:24
Vote:
 
That does not seem to be exactly true. If you perform FindPagesWithCriteria and use one of the strongly typed properties (eg. PageName or PageLink) on the PageData object as criteria it works fine. However using FindPagesWithCriteria will not find any property accessed through the property bag (eg. MainIntro) as long as the page is not published. Further trying to work around this issue and “manually” using GetChildren then looping through the returned PageDataCollection and checking any property that is not strongly typed will always return null. So there seems to be some sort of lazy loading going on. But since the MainIntro prop is visible in edit mode even though the page has not been published…there is def some way to get a hold of its value… the question is just how?? Cheers
#15608
Jan 29, 2008 11:28
Vote:
 
You're right, my bad! There is a good blog post about this subject here: http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/2/Search-for-EPiServer-pages-based-on-properties/ Are you running version 4 or 5?
#15609
Feb 26, 2008 15:29
Vote:
 
I've investigated some more, and here is some sample code (using EPiServer version 5). Note that since the page hasn't been published yet, you explicitly need to retrieve the unpublished version of the page. You can do this by adding "true" as value for parameter anyVersion when creating the PageReference. PropertyCriteriaCollection criterias = new PropertyCriteriaCollection(); PropertyCriteria pubCriteria = new PropertyCriteria(); pubCriteria.Condition = EPiServer.Filters.CompareCondition.Equal; pubCriteria.Name = "PagePendingPublish"; pubCriteria.Type = PropertyDataType.Boolean; pubCriteria.Value = true.ToString(); criterias.Add(pubCriteria); PageDataCollection matches = DataFactory.Instance.FindPagesWithCriteria( PageReference.StartPage, criterias); foreach (PageData match in matches) { //have to retrieve the unpublished version PageReference realReference = new PageReference(match.PageLink.ID, true); PageData unPublishedPageData = GetPage(realReference); //check any property value here... }
#15610
Feb 27, 2008 16:37
* 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.