Get all pages for particular page types

Viewed 470

I'm using EPiServer 11 version with EPiServer.Find. I have a requirement to fetch all pages for landingPage type and standardPage types in one query.

Can you suggest if it is possible.

3 Answers

Thanks for suggestions. I managed to solve this as below.

var results = SearchClient.Instance.Search<PageData().FilterForVisitor().FilterOnCurrentSite()
                        .Filter(x => x.MatchType(typeof(LandingPage)) | x.MatchType(typeof(StandardPage)))
                        .GetContentResult();

Hope, it helps someone.

The documentation uses searching for pages of specific type as an example so I would recommend reading that.

In your case you would just have to add both page types into the query

You could filter using MatchType or MatchTypeHierarchy.

Related