Try our conversational search powered by Generative AI!

How to get all pages of certain page type?


I want to get all pages with type of ArticlePage from a controller of a partial. 

Currently I have this code and pages is null?

        public ActionResult Navigation()
            var model = new NavigationPartialViewModel();

            var pageTypeId = ServiceLocator.Current.GetInstance<ContentTypeRepository>()

            var criterias = new PropertyCriteriaCollection
                new PropertyCriteria()
                    Condition = CompareCondition.Equal,
                    Name = "PageTypeID",
                    Type = PropertyDataType.PageType,
                    Value = pageTypeId,
                    Required = true

            var repository = ServiceLocator.Current.GetInstance<IPageCriteriaQueryService>();

            var pages = repository.FindPagesWithCriteria(

            return PartialView(model);
Oct 25, 2021 11:36

Try using FindAllPagesWithCriteria instead of FindPagesWithCriteria

FYI - FindPagesWithCriteria returns all matching pages that the current user has read access for, whereas FindAllPagesWithCriteria returns all pages regardless of permissions.

Oct 25, 2021 12:29

Something like this?

var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var contentModelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
var contentType = contentTypeRepository.Load<ArticlePage>();
var allArticlePages = contentModelUsage.ListContentOfContentType(contentType);
Oct 25, 2021 16:51
* 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.