Skip to content

Instantly share code, notes, and snippets.

@hartviglarsen
Created May 8, 2019 14:11
Show Gist options
  • Save hartviglarsen/e8aeead2147c34cdc10744deb531d170 to your computer and use it in GitHub Desktop.
Save hartviglarsen/e8aeead2147c34cdc10744deb531d170 to your computer and use it in GitHub Desktop.
public PagedResult<BlogPost> GetPagedPostsForDisplay(int page, int max, int featured)
{
var results = _blogSearcher.CreateQuery()
.NodeTypeAlias(BlogPost.ModelTypeAlias)
.Not()
.Id(featured)
.Not()
.Field(Constants.Properties.Hidden, "1")
.OrderByDescending(new SortableField(Constants.Examine.PublishedAt))
.Execute(Paging.Max(page, max));
return new PagedResult<BlogPost>(results.TotalItemCount, page, max)
{
Items = results.Skip(Paging.Skip(page, max)).Select(x => (BlogPost)_umbraco.Content(x.Id))
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment