Try our conversational search powered by Generative AI!

FindAllPagesWithCriteria with ContentReference criteria not implemented?

Vote:
 

Hello,

I'm trying to use FindAllPagesWithCriteria like so:

var criterias = new PropertyCriteriaCollection                   
                                    {                                                                  
                                        new PropertyCriteria()                            
                                        {                                
                                            Name = "BaselineReference",                                
                                            Condition = CompareCondition.Equal,                                
                                            Required = true,                                
                                            Type =  PropertyDataType.ContentReference,                              
                                            Value = pr.ToString()                       
                                        }                         
                                    };

                                    PageData page = 
                                        DataFactory.Instance.FindAllPagesWithCriteria(contentRef.ToPageReference(), criterias, "en", new LanguageSelector("en")).FirstOrDefault();
                                    

However, when reaching this code, an exception is thrown: "The Type set on the criteria is not supported: 11"

I need to use contentreference as the type because the property type im searching for is a content reference

Any ideas?

 

#73183
Jul 09, 2013 16:26
Vote:
 

Also as a side note, is there any way to move away from FindAllPagesWithCriteria and use something like ContentRepository.GetChildren?  However, GetChildren isn't recursive and only grabs the direct children, can I use this or similar to recursively find/filter pages in the heirarchy?

#73186
Jul 09, 2013 17:13
Vote:
 

Hi,


As the name implies, 'FindAllPagesWithCriteria', it searches only for pages and thereby only supports PageReference.

You can do your own method that loops through all pages and which also takes a predicate. This works in general faster for small content structures.

If you rely heavily on searches like these I would recommend EPiServer Find.

#73188
Edited, Jul 09, 2013 17:27
Vote:
 

Regarding the question on moving away from FindALlPAgesWithCriteria and using the ContentRepository instead there is the GetDecendents method that will retreive the entire tree below the selected reference

var loader = ServiceLocator.Current.GetInstance<IContentLoader>();

// all pages as ContentReference
var allPages = loader.GetDescendents(ContentReference.StartPage);

// all pages as PageData
var allPageData = allPages.Select(x => loader.Get<PageData>(x));

// filtered pageDataColleciton
var pageDataCollection = new PageDataCollection(allPageData).FilterForVisitor();
#143826
Feb 01, 2016 22:03
Vote:
 

If you have a lot of pages you might want to consider the performance implications of loading them all at once as well. Prime target for logging execution time on this one and cache the result if needed.  

#143829
Feb 01, 2016 23:00
Vote:
 

... and to add what Daniel just wrote. Do not cache the PageData objects, but rather the PageReference objects.

#143831
Feb 01, 2016 23:10
Vote:
 

...or cache the actual result you are constructing using the PageDatas. If it's a sitemap then cache the created links instead to save some memory. PageDatas can be pretty big objects x 1000s...
And make sure you don't have any authorization issues...That some pages shouldn't be displayed for certain people. Then only cache the result for anonymous users and fetch fresh for the others...

#143853
Feb 02, 2016 10:50
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.