Posts

Showing posts from April, 2020

Umbraco 8 Pagination

Umbraco 8 Pagination / Paging: @inherits Umbraco.Web.Mvc.UmbracoViewPage @{     Layout = "master.cshtml";         var pageSize = 8;     if(Model.HasValue("numberOfItemsPerPage")){     pageSize = Model.Value<int>("numberOfItemsPerPage");}         var page = 1; int.TryParse(Request.QueryString["page"], out page);     @* This line assumes you have a property called lastUpdated*@     var items = Model.Children().OrderByDescending(x => x.Value("lastUpdated"));     @* Remove the line above and use this line to keep it simple *@     @* var items = Model.Children()); *@             var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);     if (page > totalPages)     {       ...