Filter out Parent Pages by Pagetype



Can you filter out pages who's parent page is not a certain pageType. Basically, in the main site search I dont want to show pages who's Parent is a Member PageType.

Pseudo code example:

                       r => (r.ParentPage.PageType) != MemeberPageType



Aug 11, 2015 11:40

Afaik, you need to extend your model (MyPages) in order to Filter on parent page type.

Add a property to MyPages "ParentPageType" similar to this (code simplified) and use that property in your filter.

 public int ParentPageTypeId
                var parentPage = myContentLoader.Get<SitePageData>(this.ParentLink);
                return parentPage.PageTypeID;
Aug 11, 2015 12:49

Hi Mari, 

I tried to implement this use case of matching parent (container) page type and EpiFind ignore it (returns nothing).

Do I miss something, because it doesn't call this property ParentPageTypeId during debugging? 

Maybe some required Conventions needs to be included?

var newsContainerContentTypeId = _contentTypeRepository.Load<NewsContainerPage>().ID;

var dynamicSearchResult = _epiFindClient 
                    .Search<ArticlePage>(x => x
                    .Filter(f => f.Name.AnyWordBeginsWith(searchTerm) | f.MainBody.AnyWordBeginsWith(searchTerm))
                    .Filter(f => f.ParentPageTypeId.Match(newsContainerContentTypeId))



I figured out, I was missing this convention in Application_Start event.

EpiFind uses this custom property only during indexing and after just matching the indexed value in Filter() method.

      SearchClient.Instance.Conventions.ForInstancesOf<ContentPageBase>().IncludeField(x => x.ParentPageTypeId);

Edited, Mar 30, 2017 14:08
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.