Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Ignore descendants from pages with bool property "HideInSearch" = true

$
0
0

Hello,

I am new to Episerver Find, which I am implementing instead of SiteSeeker, for a customer.

The customer want to be able to choose some pages (with descendants) to not show in the search result. These pages could be of any page type or at any place in the hierarchy.
We are using a base page type that inherits from PageData, and all other page types inherit from that base page type. We will call this property "HideInSearch".

Is there a simple way to use this in a filter?

As I am new to Episerver Find I'm not totally sure how to do this.
I was thinking of to first do a search for all pages "HideInSearch" set to true, to get a list of id for these pages, then a filter like this:

.Filter(x => !x.MatchTypeHierarcy(typeof(BasePageType)) | !((BasePageType)x).Ancestors().In(idList))


But I'm not sure this is the best way?

Best Regards
Niklas


Viewing all articles
Browse latest Browse all 6894

Trending Articles